This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/31166] Integer hex constant does not follow promoting rules
- From: "schwab at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Mar 2007 22:35:02 -0000
- Subject: [Bug c/31166] Integer hex constant does not follow promoting rules
- References: <bug-31166-14238@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from schwab at suse dot de 2007-03-13 22:35 -------
(In reply to comment #2)
> So 0x80000000 is unsigned because does not fit on an int type. That's OK. If
> negating it gives an unsigned int of the same value, then, how do you explain
> that the following code prints "n1 = -2147483648"
You print it as a signed integer.
> It works because the expression should not be unsigned.
The value is converted to signed int by printf.
> The unary - operator can (and should) apply again the promotion rules, and
> should choose int.
Integer promotion is only performed on types smaller than int.
> The unary - operator can (and should) apply again the promotion rules, and
> should choose int.
The operand is unsigned int, so there is no promotion.
--
schwab at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31166