counting with 'ret' as variable allocated on stack (in function body)?
Looks equivalent to me.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
I don't know why but when I have variable declared in function (main(), it's toplevel function), it shows me crazy values. If I have it as static, it's OK.
In other words:
- You asked the wrong question
- You're making the ancient mistake of not initializing your local variables.
- You're silencing or otherwise not listening to your compiler warnings.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
I know that static variables are allocated statically, so in compilation time as data. auto variables are allocated on stack. My structure has 12bytes, but I was testing only first 4 so I thought returning is OK.
You think you know it, but you dont.
The specification does not specific where to put auto variable, it can be on register, stack, on cloud, or eliminated if it does not affect program logic.
I think that you got yourself a compiler with the PEBKAC bug enabled. It needs manual fixing.
Hint: go read forum rules 3 and 4.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]