[gnu.g++.bug] bug 12178902

rfg@ICS.UCI.EDU (12/18/89)

// bug 12178902 (1.36.1) - linkage of initialized global reference objects

// If a global reference object is initialized, g++ (1.36.1) generates
// code such that (a) space is allocated for the reference object in the
// bss segment (rather than the data segment) and (b) the initialization
// is done at run-time (rather than at compile-time).

// This has two negative consequences.

// First, if there are multiple initializations of any single global
// reference object in various files (that will later be linked together)
// then the linker is unable to catch this `multiple-initialization'
// error.

// Second, it would be more efficient to have the initialization done at
// compile time.

// Note that space for other types of global initialized objects (such as
// class & struct objects, basic type objects, and pointer type objects)
// *is* allocated (and initialized) in the data segment (rather than in
// the bss segment).  Thus, multiple initialization of these other types of
// objects (in various files) can be detected by the linker.

int i;
int &ir = i;