bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gas value truncation warning reports truncated values, doesn


From: Alan Modra
Subject: Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness.
Date: Mon, 12 Jan 2004 10:44:41 +1030
User-agent: Mutt/1.4i

On Sun, Jan 11, 2004 at 03:11:57PM +0100, Bart Samwel wrote:
> Hi guys,
> 
> We've had a discussion on the linux-kernel mailing list about a warning 
> that was generated by gas. The warning was correct, but it reported the 
> same value for the truncated and the original value. It turns out that 
> the warning prints unsigned longs, while the truncated values were 
> unsigned long longs.

The reason for this is that up until just recently, binutils has been
written in K&R C, which has no long long type.  We could not use %ll
in error messages either.  I suppose we could have written functions
to print out these errors properly, but obviously no one cared enough
to make such a contribution.

> Then I found another issue: the warning is issued 
> for ~0x80000000 (which is correct, because this yields 
> 0xffffffff7fffffff) but not for ~0x7fffffff (which is incorrect, because 
> this yields 0xffffffff80000000). The problem: the warning code assumes 
> that the value is signed, even if it is really unsigned (like ~0x7fffffff).

I think you are confused over the rules for the type of an integer
constant.  Assuming 32 bit ints, the type of 0x7fffffff is "int", but
the type of 0x80000000 is "unsigned int".  Thus ~0x8000000 is
0x7fffffff, *not* 0xffffffff7fffffff as you claim.  Note also that the
rules for decimal constants are different to those for octal and
hexadecimal.

> The attached patch (against binutils 2.14) fixes this by upgrading the 
> warning's format string to %Lx, and by taking into account the 

Thanks, but %L is glibc specific.  %ll is the correct modifier.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]