This is the mail archive of the
mailing list for the GCC project.
Re: Initialising an union
Alexandre Oliva wrote:
> Does it apply to local non-static variables? I'm pretty sure this is
> true for variables in static storage, but how about local ones?
> Unfortunately, I don't have access to the ANSI-C Standard :-(
It does. In the ANSI-C Language Referenze Version 2 A.8.7
from 31.Oct.1988 ANSI Programming Langues C, X.3.159-1989
you find the sentence:
In the first edition the initialisation of auto and register
struct's, union's or vektors was not allowed. The ANSI-C
standard allowes to use const constructors or simple
This make clear that auto and register structs/unions/vektors
can be initialised.
Also I used the same code on different platforms i.e DEC-Unix
where we use the standard C compiler which comes with the OS.
There the code works as I expected.
So now I am back that the egcs-1.0.3a has a bug here.
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:firstname.lastname@example.org