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]

Initialising an union


Hello,

I noticed a problem while initialising an union.
Here a test source:

struct a {
        int a;
};

struct b {
        int a;
        double b;
};

struct c {
        int a;
        double b;
        char c[16];
};

union x {
        int a;
        struct a as;
        struct b bs;
        struct c cs;
};

void test()
{       union x X = { 0 };
        for(;;);
        X.a++;
}

void main()
{       char    c[]="1123124213";
        test();

}

You will notice that the union X is not fully initialised. At least I noticed
that
on DecUNIX-4.0b (4.0d) Solaris-2.5.1 with the egcs version

  egcs-2.90.29 980515 (egcs-1.0.3 release)

--
Aurel Balmosan           | Department SE-SW
ORGA Kartensysteme GmbH  | phone: +49 5254 991 824
An der Kapelle 2         | fax  : +49 5254 991 749
33104 Paderborn, Germany | mailto:ab@orga.com





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