[Bug c/59933] for loop goes wild with assert() enabled
ian at g0tcd dot com
gcc-bugzilla@gcc.gnu.org
Thu Feb 20 01:00:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59933
--- Comment #13 from Ian Hamilton <ian at g0tcd dot com> ---
(In reply to Mark Warner from comment #11)
> I'm confused .. what about..
> for (k = i; k < (int)(sizeof(NSQ_del_dec_struct) / sizeof(opus_int32)); ++k)
> ... is illegal or invalid ?
> Why does it only fail if -DDEBUG is defined ?
> I mean, this code worked fine for months .. and now
What this code seems to be doing is copying a section at the end of the
sLPC_Q14 array at the beginning of the NSQ_del_dec_struct structure, plus all
the other structure members that follow the array (RandState[32], Q_Q10[32],
etc.).
It is doing this by deliberately running the sLPC_Q14 array index beyond the
end of the array, i.e. it is RELYING on undefined behaviour.
I'd have said your work-around solution is actually the better code.
More information about the Gcc-bugs
mailing list