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]
Other format: [Raw text]

Re: c/10696: linker problem with global variable


On Fri, 9 May 2003 ehrhardt@mathematik.uni-ulm.de wrote:

>     Not a bug! As defined in 6.2.2 foo_global has external linkage in
>     both translation units, hence both identifiers refer to the same object.

Actually, the multiple definitions cause undefined behavior, no diagnostic
required.  The reported behavior (allowing multiple definitions in
different translation units, provided no more than one is initialized) is
conventional on Unix.  If the reporter wants a diagnostic at link time,
compile with -fno-common or link with -Wl,--warn-common (if using GNU
binutils).

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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