[Bug c++/12056] New: string literal in extern inline function not unique

jbeulich at novell dot com gcc-bugzilla@gcc.gnu.org
Mon Aug 25 16:02:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12056

           Summary: string literal in extern inline function not unique
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbeulich at novell dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

The standard says (7.1.2 § 4) "A string literal in an extern inline function is
the same object in different translation units". The compiler, not emitting a
(generated) symbol, for string literals, cannot guarantee this, resulting in
address comparisons on the address of such literals obtained through different
instances of the same function to not match.

extern inline const char*test() {
	return "xyz";
}

const char*test1(int i) {
	return test() + i;
}



More information about the Gcc-bugs mailing list