This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/10696: linker problem with global variable
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: ehrhardt at mathematik dot uni-ulm dot de, bhuang at qubit-star dot com, gcc-bugs at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
- Date: Fri, 9 May 2003 12:24:44 +0100 (BST)
- Subject: Re: c/10696: linker problem with global variable
- References: <20030509093207.27249.qmail@sources.redhat.com>
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