O3 versus O2 weirdness
Bartlomiej Dolata
doli@ibt.com.pl
Mon Apr 16 13:48:00 GMT 2007
Hi Eljay and thanks for the answer.
>
>> char komb[13];
>
> The buffer isn't large enough to hold the output, so the output
overflows
> and (probably) overwrites something important.
>
That buffer you pointed at was not the culprit of the problem (I increased
it to 64 and the program still had erratic behaviour), but it pointed me
into a right direction.
The problem was atoi function call:
..
char c;
..
l=atoi(&c);
..
when I changed it to:
..
char c[2]="";
..
c[0]=konfig[i];
l=atoi(c);
..
It seems to work fine.
I know it is my programming error (atoi manpage states it takes a string
as input), but isnt there really a way of detecting such ?
This was particularly easy sample but chasing such bugs in a big code
can be a really painful task...
Thanks,
B
More information about the Gcc-help
mailing list