This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Bug Report: Bug in Header files for SPARC platform



Hi,

I thing I have found a small bug in the header-files of gcc-2.95.1:

One-line description: 

  Compiler and header-files disagree about the size of int


Platform:  
 Solaris 2.7, on SPARC Ultra 5 (UltraIIi 270Mhz)

Version:
 gcc 2.95.1

 configuration options: default

Minimal program that reproduces the bug:

#include <limits.h>
long test=LONG_MAX;

compile as c: 
gcc -mcpu=ultrasparc -c test.c
longtest.c:3: warning: overflow in implicit constant conversion

compile as c++:
longtest.cc:3: integer constant out of range
longtest.cc:3: warning: decimal integer constant is so large that it is
unsigned


I believe the cause of this Problem to be this line in limits.h, line 79

#if defined (__alpha__) || defined (__sparc_v9__) || defined (__sparcv9)
#define __LONG_MAX__ 9223372036854775807L

or the line in the specs-file that define __sparc_v9__

%{mcpu=v9:-D__sparc_v9__}

This is of course depending on the interpretation of the __sparc_v9__ define.
In SUN Nomenclatura (see 'man as' on solaris), architecture v9 means 64bit
binary format. There is an 'architecture' v8plus, which is basically 
ultra-sparc in 32-bit mode. This is what we want here. 
But since the -mcpu-Switch is about CPUs and  not about binary formats, v9 
might still be the better naming choice. 

Fix:
To get it right, there needs to be a define that reflects if the
compiler is generating 32 or 64 bit code. I have, however, not found 
any such thing.

OTOH, I noticed that the spec-file for the sparc64 platform defines
__sparc_v8__ when gcc is invoked with -m32, -mcpu=v9. This looks like a
workaround to me.

Regards,

Jo Deisenhofer

_____________________________   ____
Johannes Deisenhofer         \ /          Hexmac Software Systems 
Server Technologies         hexmac        (http://www.hexmac.com)
Email: jo@hexmac.com     ____/ \__________________________________


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