[llvm-bugs] [Bug 37844] New: clang++ does not produce error messages

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 19 01:02:11 PDT 2018


            Bug ID: 37844
           Summary: clang++ does not produce error messages
           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

The code is as follow:

namespace N {
 extern "C" {
 extern const int foobar;
 const int foobar = 1;
 struct S { static const int foobar; };
 const int S::foobar = 2;
int main () { return !(N::foobar + 1 == N::S::foobar); }

clang++ accepts the code, but g++ produces error messages:

conflicting declaration of ‘const int N::S::foobar’ with ‘C’ linkage
      const int S::foobar = 2;
previous declaration with ‘C++’ linkage
      struct S { static const int foobar; };

Indeed, the code comes from a bug report of gcc
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33786). A previous version of g++
produces a different error message, but was fixed in the latest version. Martin
Sebor analyzed why the above code is ill-formed. Please check this problem.

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/20180619/4601ec95/attachment.html>

More information about the llvm-bugs mailing list