This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/60578] wrong code (that hangs) at -O0 on x86_64-linux-gnu (affecting all gcc versions)
- From: "su at cs dot ucdavis.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 19 Mar 2014 05:44:12 +0000
- Subject: [Bug c/60578] wrong code (that hangs) at -O0 on x86_64-linux-gnu (affecting all gcc versions)
- Auto-submitted: auto-generated
- References: <bug-60578-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60578
--- Comment #2 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Andrew Pinski from comment #1)
> J and n are both uninitialized so there is undefined code and the result is
> different between x86 and amd64 due to different register being selected and
> it just happens the amd64 one register was set to zero. So invalid set j and
> n.
Andrew, no, the code doesn't have any undefined behavior. If you look at the
code more carefully, you'll see that neither
for (; j;)
m = 0;
(because i = 0, so the loop body isn't executed)
nor
for (; n;)
;
(because (c ^ 0L) < -1 is true in 64-bit, so the code returns)
is executed.
I think the issue is that integer promotion for "(c ^ 0L) < -1" isn't correct.