[Bug c/42799] Variable unexpectedly set to 0 because a scanf()

2010-01-19 Thread jakub at gcc dot gnu dot org
--- Comment #3 from jakub at gcc dot gnu dot org 2010-01-19 10:21 --- This is undefined behavior, scanf is writing int value into an unsigned short variable, so it of course can overwrite whatever happens to be adjacent to that var on the stack. Use %hd instead of %d to write to short/un

[Bug c/42799] Variable unexpectedly set to 0 because a scanf()

2010-01-19 Thread adriyetichaves at gmail dot com
--- Comment #2 from adriyetichaves at gmail dot com 2010-01-19 10:04 --- Same code compiled in other compiler (Turbo C++) works. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42799

[Bug c/42799] Variable unexpectedly set to 0 because a scanf()

2010-01-19 Thread adriyetichaves at gmail dot com
--- Comment #1 from adriyetichaves at gmail dot com 2010-01-19 09:59 --- I've simplified the code, step by step (though that removing functions would change the result), but this simple code still gets the same error: #include int main(void) { unsigned short int q_num, idade, p, dime