Mail Archives: djgpp/1998/07/07/05:30:35
Jedediah Smith (jedediah AT interlog DOT com) wrote:
: In the middle of a function I had something like this:
:
: MyFunction()
: {
: ...
:
: {
: char myString[20];
:
: // myString is used only in here
:
: }
:
: ...
: }
:
: My intention was to have myString allocated at the beginning of the code
: block and deallocated at the end. Clearly myString was not getting
: allocated at all because I was getting protection faults in the code
: that used it. When I moved the myString declaration to the beginning of
: the function, it worked fine. Should myString have been allocated in the
: above example, or do I have my C++ syntax wrong?
I don't know much about C++, but as the above look like C, let me
answer. Yes, myString is allocated. Look in the assembler file
generated with -S option to see that. This behaviour (crashing) can be
caused by a run-away pointer. You can get similar results (crashing
ceases) by moving around some code in your source.
If you still thinks it's an error in GCC then post some code that
exhibits this behaviour.
Silence,
MartinS
- Raw text -