Just confused, why is not mL = 1?
Asked
Active
Viewed 212 times
1
-
6Because it's not initialized yet? What happens if you step once more? – Some programmer dude Mar 22 '14 at 07:14
-
4That assignment hasn't yet run; the breakpoint on that line indicates that the debugger should stop just *before* that code. Step again and you'll see the correct value. – dlev Mar 22 '14 at 07:14
-
1Yeah step once more and you will get it as 1 – vaibhav kumar Mar 22 '14 at 07:14
-
the bigger question is...why 400/400?? :) – ryrich Mar 22 '14 at 07:16
-
Thanks guys, I had a equation there with the output 1. Changed it to 400/400 for simplicity. – Alice Mar 22 '14 at 07:24
-
Why is this tagged C and C++ ? You should know in which language you are writing your programs. – Jens Gustedt Mar 22 '14 at 07:35
1 Answers
3
Visual studio treats int mL = 400/400
as two step process.
First step would be allocating memory in stack. So, you see a garbage value. Press F10/F11 (step once more) you should see 1.
-858993460 translates to 0xCCCCCCCC which is a bit pattern used by Microsoft compilers to detect buffer overruns and to initialize an empty stack.Some more details here - softwareverify.com/memory-bit-patterns.php
-
1It is *not* a garbage value, -858993460 has a well defined meaning. That it appears more than once in the OP's screenshot is also not an accident. Convert it to hex to see that it is special. – Hans Passant Mar 22 '14 at 07:51
-
and this value often appears in debug mode. It helps debugging in many situations – phuclv Mar 22 '14 at 08:30
-
It is nothing special. It is 0xCCCCCCCC. This bit pattern is often used by MS compilers. I Couldn't find it officially in MFC or Win32 but I guess this could help - http://www.softwareverify.com/memory-bit-patterns.php – Mohan Mar 22 '14 at 08:41
-
[When and why will an OS initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete?](https://stackoverflow.com/q/370195/995714) – phuclv Aug 18 '18 at 11:13