This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gas will miscompile with SPARCompiler 3.0.1 on Solaris7


On 7 Apr 2000, Ian Lance Taylor wrote:

>    From: Alexandre Oliva <aoliva@cygnus.com>
>    Date: 07 Apr 2000 01:07:56 -0300
> 
>    > Alexandre, to get this result your sun compiler apparently is sign
>    > extending 0xffffffff.
> 
>    Precisely.  So, it's a compiler bug.  Anyway, it would be nice to fix
>    it, wouldn't it?  Here's a patch that fixes this and a few other
>    similar bugs.  With this patch, `make check-{gas,binutils}' passes all
>    tests.  Ok to install?  Release branch?
> 
>    -      val = ((val & 0xffffffff) ^ sign) - sign;
>    +      val = ((val & (unsigned)0xffffffff) ^ sign) - sign;
> 
> Casts to a type of unknown size should only be used in unusual
> circumstances.

There are plenty of other places where we assume that "int" and
"unsigned int" are at least 32 bits.  Are these all bugs?

>  I don't really want to add them merely to work around
> a bug in a proprietary compiler.

I mildly disagree with this philosophy.  binutils is one of the
"bootstrap" packages.  We really should cater to old compilers, much in
the same way as gcc tries to.  The whole world isn't linux (yet) ;-)

>  Besides, adding casts this way is
> just a wart; any future maintainer would be right to simply remove
> them, since they are clearly unnecessary.

N_ONES is more of a wart, IMNSHO.  How about using

#ifdef __STDC__
#define UNSIGN(x) x ## U
#else
#define UNSIGN(x) ((unsigned) x)
#endif

-- 
Linuxcare.  Support for the Revolution.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]