Description of problem: gcc doesn't appear to correctly allocate memory for a variable Version-Release number of selected component (if applicable): gcc-3.4.2-6.fc3 gdb-6.1post-1.20040607.43 glibc-2.3.4-2.fc3 How reproducible: I tried everything I could to get it to work. I spent about 4 hours on this issue with no solution other than the one described below. Steps to Reproduce: <shortened code snippet begins> static int dbug12_get_reply (unsigned char *packet) { return 5; } void dbug12_stop_reason (enum dbug12_stop *reason, int *sigrc) { int replyEnd; unsigned char reply[254]; // This line is needed //to make the code work replyEnd = 0; // get the reply replyEnd = dbug12_get_reply(reply); printf("Reply is %s\n",reply); // handle the error condition // can't pass here with a zero length if (replyEnd == 0) ... <end of shortned code snippet> Problem #1: gdb cannot find replyEnd: (gdb) whatis replyEnd No symbol "replyEnd" in current context. Problem #2: The code doesn't execute properly if I delete the "replyEnd = 0;" line. Without "replyEnd = 0;" in the code, replyEnd gets an unalterable junk value. With "replyEnd = 0;" in the code, replyEnd gets set to the return value of 5, which it should. I was also playing around with changing the size of the reply buffer, ie "reply[255]", reply[253], etc. It didn't look like gcc was changing the size of the buffer on a clean build. Additional info: If the included code snippet doesn't reproduce the problem, I can provide the volumous code sample that does. gcc is being run from kdevelop. The gcc command line switches used are -ggdb only.
Such incomplete snippets are useless, only self-contained (and ideally preprocessed) testcase helps. BTW, you are printing uninitialized buffer in the incomplete snippet above. I have cut'n'pasted it and fixed it so that it compiles, but replyEnd var is definitely there, visible to the debugger and removing replyEnd = 0; doesn't change anything.
I stripped everything out of dbug12_get_reply(). It used to set a value for reply. How are you confirming that varEnd is there for the debugger to use ? I mean, where and how are you confirming that the var is getting created and/or set ? Adding and removing replyEnd changes whether or not replyEnd gets the return value from dbug12_get_reply() on my machine. gdb cannot get replyEnd no matter what I do. I'll see if I can create a test case or better illustrate what is going on.
Have you managed to create a test case yet? Without it it is really hard to talk about this.
Closing until you provide a testcase. When you have it, please reopen.