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]

producing invalid assembly code


gcc seems to be willing to produce invalid assembly code under some
circumstances.  As the typescript below indicates, I first noticed this
with a rather old gcc; however, someone who has 2.95.3 running tells me
this test works (or rather, doesn't work) the same way under it.

I'll be happy to test patches, if they can be adapted to my compiler
version.  (Which seems likely, since it's probably in a piece of code
common to a lot of versions.)  Even if they won't apply cleanly, I'd
welcome a copy of any patches anyone comes up with; switching compiler
versions would probably be a lot more trouble for me at this point than
backporting patches.

The test below was run on a sparc.  However, I see essentially the same
(mis)behavior on all processors I have ready access to: sparc, i386,
vax, 68k, powerpc, and alpha.  (My correspondent with 2.95.3 didn't
mention trying anything but sparc.)  Most of them are using ELF as
their object/executable file format, but the VAX is using a.out; it
reported __fail_x multiply defined, rather than _fail_x.

If I can help further with this, just drop me a line.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Script started on Mon Apr 23 20:22:44 2001
[Sparkle] 1> cat zz.c
struct frame;
struct inst;
struct descriptor_data;

typedef int dbref;

#define UNUSED_ARG(x) x __attribute__((__unused__))
#define PRIM(name)\
extern void prims_##name(dbref, dbref, struct inst *, struct inst *, int *, struct frame *);    \
void prims_##name(                      \
        UNUSED_ARG(dbref player),       \
        UNUSED_ARG(dbref program),      \
        UNUSED_ARG(struct inst *pc),    \
        UNUSED_ARG(struct inst *arg),   \
        UNUSED_ARG(int *top),           \
        UNUSED_ARG(struct frame *fr)    \
        )
extern void interp_err(dbref, dbref, const char *, const char *);
extern char *insttotext(struct inst *);
extern int foo(int);
extern void bar(int, struct descriptor_data *);

#define ABORT_INTERP(s) \
do { interp_err(player,program,insttotext(pc),(s)); return; } while (0)

static struct descriptor_data *desc_num_(int n, void (*fail)(void))
{
 n = n;
 fail = fail;
 return(0);
}

#define desc_num(n) desc_num_1((n),__LINE__)
#ifdef EXHIBIT_BUG
#define desc_num_1(a,b) desc_num_2(a,x)
#else
#define desc_num_1(a,b) desc_num_2(a,b)
#endif
#define desc_num_2(n,l) \
        ({ __label__ _fail_label;                                       \
           static void _fail_##l(void) __attribute__((__noreturn__));   \
           static void _fail_##l(void) { goto _fail_label; }            \
           if (0)                                                       \
            { _fail_label:                                              \
              ABORT_INTERP("Invalid descriptor number.");               \
            }                                                           \
           desc_num_((n),&_fail_##l);                                   \
         })

PRIM(condbref)
{
 struct descriptor_data *d;

 d = desc_num(foo(1));
 bar(1,d);
}

PRIM(conidle)
{
 struct descriptor_data *d;

 d = desc_num(foo(2));
 bar(2,d);
}
[Sparkle] 2> /usr/bin/gcc -c zz.c
[Sparkle] 3> /usr/bin/gcc -c zz.c -DEXHIBIT_BUG
/tmp/ccU5H3Pg.s: Assembler messages:
/tmp/ccU5H3Pg.s:158: Fatal error: Symbol _fail_x already defined.
[Sparkle] 4> /usr/bin/gcc --version
egcs-1.1.2
[Sparkle] 5> exit
Script done on Mon Apr 23 20:23:08 2001


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