Article View: gnu.gcc.bug
Article #6001A bug, I guess...
From: Leigh Clayton
Date: Thu, 26 Dec 1996 00:00
Date: Thu, 26 Dec 1996 00:00
104 lines
4170 bytes
4170 bytes
Hi. I'm using gcc 2.6.3 in a Linux (1.2.3) system. I've come across what
looks to me like a bug. I am not very sure exactly how I should accomplish
(if I even can) this particular sort of initialisation/definition; in fact
my other compilers (various levels of AIX compiler) croak with errors of
one sort or another. But gcc quietly produces bad assembler code, so I
thought you'd likely want to hear about that, at least. If you can tell me
how I should accomplish my intent, that would be great, but don't sweat that.
For reasons I won't bore you with, I want to make a vector of pointers,
each pointing at an instance of a structure. I want to define this thing
dynamically (ie, I want to initialise it in-place, without specifying its
final size explicitly).
I've used the following C source to attempt this:
----------------------------------------startC----------------------------
#define MAXtoken 25
static char Rhost[MAXtoken+1]="";
static int *Ruser=0;
static struct token_s {
char * tname;
enum ttype_e {
ttint=1,
ttstring=2,
} ttype;
void *tptr;
};
typedef struct token_s token_t;
typedef token_t *token_p;
static token_p xx[]={ &(token_t) {"foo",ttint, (void *)&Rhost},
&(token_t) {"goo",ttint, (void *)&Rhost},
&(token_t) {"hoo",ttint, (void *)&Rhost},
(token_p) 0};
----------------------------------------endC------------------------------
This compiles without error, but produces the following assembler code,
which you'll notice incorrectly refs LC6 in each token_t as the text
pointer; this ultimately leads to a failing link.
(The compile command string was: gcc -c -S gccbug.c )
------------------------------------StartS--------------------------------
.file "gccbug.c"
gcc2_compiled.:
___gnu_compiled_c:
.data
_Rhost:
.ascii "?0"
.space 25
.align 2
_Ruser:
.long 0
.align 2
_xx:
.long LC1
.long LC3
.long LC5
.long 0
.text
.align 2
LC5:
.long LC6
.long 1
.long _Rhost
LC4:
.ascii "hoo?0"
.align 2
LC3:
.long LC6
.long 1
.long _Rhost
LC2:
.ascii "goo?0"
.align 2
LC1:
.long LC6
.long 1
.long _Rhost
LC0:
.ascii "foo?0"
---------------------------EndS------------------------------------
As I said, I welcome any comments, although I will most likely just try to
find a simpler way to solve my problem, and likely won't upgrade my gcc
(at least right now); I just wanted to report the bug for your interest.
Thanks for the software ..../Leigh
--------------------------------------------------------
... so when they begin to hanker after office, and find that they cannot
achieve it through their own efforts or on their merits, they begin to
seduce and corrupt the people in every possible way, ... the result is
that through their senseless craving for prominence they stimulate among
the masses both an appetite for bribes and the habit of receiving them,
and then the rule of democracy is transformed into government by violence
and strongarm methods.
Polybius; The Rise of the Roman Empire, Book VI, 9.
--------------------------------------------------------
Leigh Clayton loc@Soliton.COM
Technical Details
Message-ID:
<199612270048.AA17841@yrloc2.tor.soliton.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,7ed7d245cce26b7d,start X-Google-Attributes: gid113d02,public From: loc@Soliton.COM (Leigh Clayton) Subject: A bug, I guess... Date: 1996/12/26 Message-ID: <199612270048.AA17841@yrloc2.tor.soliton.com> X-Deja-AN: 206117371 sender: bug-gcc-request@prep.ai.mit.edu organization: Soliton Associates Limited x-gateway: relay2.UU.NET from bug-gcc to gnu.gcc.bug; Thu, 26 Dec 1996 19:48:36 EST x-mail: 2100/44 Victoria St., Toronto, Canada, M5C 1Y2 x-telephone: +1 (416) 364-9355 X229 Fax +1 (416) 364-6159 reply-to: loc@Soliton.COM (Leigh Clayton) newsgroups: gnu.gcc.bug