[llvm-bugs] [Bug 37885] New: static object mangling conflicts

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 20 19:24:26 PDT 2018


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

            Bug ID: 37885
           Summary: static object mangling conflicts
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

I found that gcc+ produces errors when it compiles the following code:
extern "C" void abort();
static int i;
int *p = &i;
int main()
{ 
 int i;
 { 
 extern int i;
 i = 1;
 *p = 2;
 if (i == 2)
 abort ();
 }
 return 0;
}

When compiling the above code, clang++ does not produce any errors. The code
comes from https://bugs.llvm.org/show_bug.cgi?id=5966

Indeed, the situation is more complicated. The above bug report of clang says
that the code comes from a bug report of gcc:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775

I reported the difference to gcc:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86181

After reading the bug report, Richard Biener made the following comment: "I
think the clang bug is incomplete and misses the 2nd TU which defines i.  So
GCC works (and the testcase is in the testsuite)."

Is this a recurring bug in clang? Hope that the comment from Richard Biener can
further improve clang.

-- 
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/20180621/14ff21b8/attachment.html>


More information about the llvm-bugs mailing list