Click here to Skip to main content
15,923,083 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Local Variable Address off by 4 bytes Pin
Maxwell Chen17-Mar-08 20:56
Maxwell Chen17-Mar-08 20:56 
GeneralRe: Local Variable Address off by 4 bytes Pin
ForNow17-Mar-08 21:54
ForNow17-Mar-08 21:54 
GeneralRe: Local Variable Address off by 4 bytes Pin
Mark Salsbery18-Mar-08 8:21
Mark Salsbery18-Mar-08 8:21 
GeneralRe: Local Variable Address off by 4 bytes Pin
ForNow18-Mar-08 12:40
ForNow18-Mar-08 12:40 
GeneralRe: Local Variable Address off by 4 bytes Pin
Mark Salsbery18-Mar-08 13:07
Mark Salsbery18-Mar-08 13:07 
GeneralRe: Local Variable Address off by 4 bytes Pin
ForNow18-Mar-08 14:59
ForNow18-Mar-08 14:59 
GeneralRe: Local Variable Address off by 4 bytes Pin
ForNow18-Mar-08 15:54
ForNow18-Mar-08 15:54 
GeneralRe: Local Variable Address off by 4 bytes Pin
Mark Salsbery18-Mar-08 16:13
Mark Salsbery18-Mar-08 16:13 
Thanks!

The stack frame on entry to the function should look something like this
(after the stack frame is built, working downward in memory):

4 bytes: Passed reference argument (passed as a pointer probably)
4 bytes: Return address
256 bytes: local array
<--- esp points here

The compiler is free to align the local variables and add any integers
or whatever it needs for the stack frame, so to rely on a certain esp value
would require knowing exactly how the compiler builds the stack frame, which
will vary between compilers and compiler settings.

That aside, you found the culprit. I'm not sure why the code to add the null terminator
wouldn't be in the compiled code! Smile | :)

Maybe try this - add symbolic debug info to your release build configuration.
Then when you run it in the debugger you can still debug easy.

adding debug symbols to release builds[^]

Also for what it's worth, you can simplify this line:

number = atoi((const char *)&holdstr[0]);

to

number = atoi(holdstr);

I'll take a look at it here - please let me know what you find!

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Local Variable Address off by 4 bytes Pin
ForNow18-Mar-08 18:32
ForNow18-Mar-08 18:32 
QuestionRe: Local Variable Address off by 4 bytes Pin
Mark Salsbery18-Mar-08 19:40
Mark Salsbery18-Mar-08 19:40 
GeneralRe: Local Variable Address off by 4 bytes Pin
Mark Salsbery19-Mar-08 4:39
Mark Salsbery19-Mar-08 4:39 
GeneralRe: Local Variable Address off by 4 bytes Pin
ForNow19-Mar-08 14:39
ForNow19-Mar-08 14:39 
GeneralYou were right !!!!! Pin
ForNow19-Mar-08 17:35
ForNow19-Mar-08 17:35 
Generalurgent Pin
john563217-Mar-08 20:00
john563217-Mar-08 20:00 
GeneralRe: urgent Pin
rp_suman17-Mar-08 20:39
rp_suman17-Mar-08 20:39 
GeneralRe: urgent Pin
john563217-Mar-08 20:42
john563217-Mar-08 20:42 
GeneralRe: urgent Pin
rp_suman17-Mar-08 21:55
rp_suman17-Mar-08 21:55 
GeneralRe: urgent Pin
David Crow18-Mar-08 3:55
David Crow18-Mar-08 3:55 
GeneralRe: urgent Pin
Naveen17-Mar-08 21:21
Naveen17-Mar-08 21:21 
GeneralRe: urgent Pin
john563217-Mar-08 22:50
john563217-Mar-08 22:50 
GeneralRe: urgent Pin
Naveen17-Mar-08 23:29
Naveen17-Mar-08 23:29 
GeneralRe: urgent Pin
john563218-Mar-08 0:08
john563218-Mar-08 0:08 
GeneralRe: urgent Pin
Naveen18-Mar-08 0:19
Naveen18-Mar-08 0:19 
GeneralRe: urgent Pin
john563218-Mar-08 0:29
john563218-Mar-08 0:29 
GeneralRe: urgent Pin
fat_boy18-Mar-08 2:47
fat_boy18-Mar-08 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.