https://bugs.llvm.org/show_bug.cgi?id=41458

            Bug ID: 41458
           Summary: need to mangle string literal objects in inline
                    variable initializers
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++'17
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Testcase:

  inline const char *const str = "foo";
  const char *p = str;

For this, Clang emits:

  @.str = private unnamed_addr constant [4 x i8] c"foo\00", align 1
  @p = dso_local global i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str,
i32 0, i32 0), align 8

... which is incorrect. 'str' is required to have a single value across
translation units, so the same string literal object must be used as its
initializer in all cases.

We need to give the string literal a mangling in this case. The Itanium ABI
doesn't specify a mangling for this case; I've filed
https://github.com/itanium-cxx-abi/cxx-abi/issues/78 for that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to