Linux-kernel mailing list archive 1998-31,: Broken fix for gcc-2.7 breakage wrt empty structures in 2.1.115-4

# Broken fix for gcc-2.7 breakage wrt empty structures in 2.1.115-4

Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Wed, 05 Aug 1998 20:27:23 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Shawn Leas: "A plea to end the SPAM!!!"
- Previous message: Horst von Brand: "2.1.115-4 and SPARC64"

The gcc-2.7.2.3 and earlier bug is architecture independent AFAIK (at least
i586-linux, SPARC-solaris are affected), but it's only fixed (halfway?) by:

> ---
> v2.1.114/linux/include/asm-i386/spinlock.h Mon Aug 3 17:48:28 1998
> +++ linux/include/asm-i386/spinlock.h Tue Aug 4 13:15:49 1998
> @@ -9,9 +9,16 @@
>
> /*
> * Your basic spinlocks, allowing only a single CPU anywhere
> + *
> + * Gcc-2.7.x has a nasty bug with empty initializers.

The bug is with empty initializers for empty structures after bitfields. My
original bug report for gcc (May 01, 1997) has the example:

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

> */
> -typedef struct { } spinlock_t;
> -#define SPIN_LOCK_UNLOCKED { }
> +#if (__GNUC__ > 2) || (__GNUC_MINOR__ >= 8)

_I_ do know there was no gcc-1.8... but why not do it cleanly? It costs an
infinitesimal extra amount of time while compiling, perhaps. Use the
following to check if the error is present:

#if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR <= 7)

> + typedef struct { } spinlock_t;
> + #define SPIN_LOCK_UNLOCKED { 0 }

So an empty structure gets initialized with a structure containing 0!?

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

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

- Next message: Shawn Leas: "A plea to end the SPAM!!!"
- Previous message: Horst von Brand: "2.1.115-4 and SPARC64"