| View previous topic :: View next topic |
| Author |
Message |
Jens Bęk Nielsen
Joined: 07 Jul 2011 Posts: 206 Location: Denmark
|
Post subject: Re: Finding errors where indexes goes beyond their boudaries Posted: Mon May 07, 2012 3:07 pm |
|
|
Sven; I have not expressed myself clearly.
Of course the error should be detected at runtime.
The compiler should generate the code to do that with a switch, so it can be turned off in the final compile.
And from what you write it is possible with some compilers.
I do not know about assert(), but it seems to be a possibility?!
But I have +50 arrays in dabbaba to change...
I am only an amateur in C programming - dabbaba is the only program I have written in C.
And all the 12.000 lines of code is in one single file...
My proffession is being a mainframe-programmer, though (cobol, cics, db2, tso...).
Since 2008 I have used the Pelle compiler.
But I think it may produce wrong code, and I have never learnt how to debug with it.
I would also like to try performance profiling.
So I changed to DevCpp a week ago.
And it found the access violation I was not aware of - dabbaba seems to run ok with it...
Could an interpreter detect this?!
DevCpp found the "An access Violation (Segmentation Fault)" here:
void change_to_pili( char *pili, char *sqfr, char *sqto)
{ char *p, p=pili;
loop: if (*p!=*sqfr) {++p; goto loop;}
*p=*sqto; <--------------------------------------------------------------------
}
But the real error is, that pili does not contain the value *sqfr.
I assume it has been overwritten by an index going beyond its boundaries.
It may take some time for the interpreter.
The access violation happens after 500.000 nodes - 5 seconds.
Thanks for your helpful posts! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|