This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Bug (?) in initialization code.
- To: binutils at sourceware dot cygnus dot com, gcc-bugs at gcc dot gnu dot org
- Subject: Bug (?) in initialization code.
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Thu, 16 Mar 2000 14:44:02 -0500 (EST)
- Cc: lucier at math dot purdue dot edu (Brad Lucier), feeley at iro dot umontreal dot ca
The following program:
/* compile with gcc -c foo.c on alpha */
typedef int int32;
typedef long int64;
typedef struct { int a; int b; } foo;
extern foo f;
static int32 tbl1[] =
{
(int32) &f
};
static int64 tbl2[] =
{
(int64) &f
};
static foo* tbl3[] =
{
&f
};
compiled on alphaev6 with any gcc version I tried from 2.95.1 on
bombs and gives the following error message:
foo.c:13: initializer element is not computable at load time
foo.c:13: (near initialization for `tbl1[0]')
The problem seems to be that gcc thinks the loader cannot stuff
a 64bit pointer into a 32bit int at load time.
On the other hand, ccc, the Compaq compiler, gives the following
warning on alphaev6-unknown-linux:
cc: Warning: foo.c, line 12: In the initializer for tbl1[0], the value of the address has been truncated. (statictrunc)
(int32) &f
----------^
ccc does not implement -taso on this platform even though
more recent versions of ld supposedly support it.
I intend to use the -taso flag with ld 2.9.5.0.27 (H. J. Lu's release).
So, the questions:
1. Can the loader handle this construct correctly, given the -taso flag?
2. Should gcc allow this construct?
By the way, this works fine using cc on True64.
Brad Lucier