gcc bug tickled by non-SMP linux-2.1.37-pre2

Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Thu, 1 May 1997 20:15:56 -0400


[This message has also been posted.]
I recently reported that .../arch/i386/kernel/init_task.c crashes
gcc-2.7.2.2.f.2. Further investigation uncovered a subtle bug tickled by
the union init_task_union initialization, due to the fact that spinlock_t is
defined as an empty struct in .../include/asm-i386/spinlock.h, and is
initialized as such here. I just reported the bug to the gcc folks, see
below and enjoy (or weep, as the case may be). I hate to put something into
spinlock_t just to get away with this (gcc does optimize empty structs
away). Any other thoughts?

/*
* This jewel crashes gcc's cc1...
* The bitfield at the beginning is necesary (a plain int won't do),
* any intervening fields don't seem to matter.
*
* Compile with, e.g.:
*
* gcc -c tst.c
*
* and watch the fireworks ;-0
*
*
* gcc-2.7.2.2 + g77-0.5.20, no further patches
*
* Reading specs from /usr/lib/gcc-lib/i586-linuxlibc1/2.7.2.2.f.2/specs
* gcc version 2.7.2.2.f.2
*
* Build CFLAGS for gcc where:
*
* -O2 -fomit-frame-pointer \
* -malign-functions=2 -malign-jumps=2 -malign-loops=2
*
* Made the three stages, no differences between stage2 and stage3
*/

struct {
int i:1;
struct { } e;
}
crashit = { 0, {} };

-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Viņa del Mar, Chile                               +56 32 672616