[llvm-bugs] [Bug 28259] New: clang accepts illegal C++ code with invalid A::A variable declaration

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 22 00:10:22 PDT 2016


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

            Bug ID: 28259
           Summary: clang accepts illegal C++ code with invalid A::A
                    variable declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk (and all versions at least as early as 3.2) accepts the
following C++ code, which is illegal according to the C++ language standard
(page 53, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf): 

struct A { A(); };
...
A::A a;   // error, A::A is not a type name  


$ clang++ -v
clang version 3.9.0 (trunk 273248)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ clang++ -c small.cpp
$ 
$ g++-6.1 -c small.cpp
small.cpp: In function ‘void foo()’:
small.cpp:5:3: error: ‘A::A’ names the constructor, not the type
   A::A a;
   ^
small.cpp:5:8: error: expected ‘;’ before ‘a’
   A::A a;
        ^
small.cpp:5:9: error: statement cannot resolve address of overloaded function
   A::A a;
         ^
$ 


----------------------


class A {};

void foo ()
{
  A::A a; 
}

-- 
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/20160622/08f0f4d7/attachment.html>


More information about the llvm-bugs mailing list