[Bug c/60578] wrong code (that hangs) at -O0 on x86_64-linux-gnu (affecting all gcc versions)

su at cs dot ucdavis.edu gcc-bugzilla@gcc.gnu.org
Wed Mar 19 06:22:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60578

--- Comment #5 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Jakub Jelinek from comment #4)
> But why do you think (c ^ 0L) < -1 is 1 for 64-bit mode?
> From C99, 6.3.1.8, different paragraphs apply:
> "Otherwise, if the type of the operand with signed integer type can represent
> all of the values of the type of the operand with unsigned integer type, then
> the operand with unsigned integer type is converted to the type of the
> operand with signed integer type.
> 
> Otherwise, both operands are converted to the unsigned integer type
> corresponding to the type of the operand with signed integer type."
> 
> For 64-bit mode, the first cited paragraph applies, because 64-bit long int
> can
> represent all of values of 32-bit unsigned int, so it is
> (((long int) 0) ^ 0L) < -1L and thus 0L < -1L and therefore false.
> 
> For 32-bit mode, the second cited paragraph applies, because 32-bit long int
> can't represent all of values of 32-bit unsigned int, so it is
> (((unsigned long int) 0) ^ 0UL) < -1UL and thus 0UL < -1UL and therefore
> true.

Thanks Jakub!  Sorry for the invalid report.



More information about the Gcc-bugs mailing list