------- Comment #10 from brian at dessent dot net 2008-09-18 10:45 ------- Subject: Re: Loop incorrectly optimized to endless loop with -Os/-O2/-O3
That fact that the hardware allows it doesn't change the fact that it's still invalid in ISO C, and that is the spec that gcc follows. Seems to me you can avoid invoking undefined behavior by: uint16 i = 0x0FFE, sum = 0; do { i -= sizeof (uint16); sum += *((uint16 *)i); } while (i); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37569