[llvm-bugs] [Bug 41458] New: need to mangle string literal objects in inline variable initializers

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 10 14:19:40 PDT 2019


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: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190410/de680210/attachment.html>


More information about the llvm-bugs mailing list