[llvm-bugs] [Bug 46231] New: Clang accepts empty declaration in a template declaration

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 6 23:18:54 PDT 2020


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

            Bug ID: 46231
           Summary: Clang accepts empty declaration in a template
                    declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hi, there,

clang accepts this code --- test.cc:

template<class> ;
int main(){return 0;}

which contains a empty declaration in a template declaration.

In clang-trunk, clang just give a warning and then compile it successfully.

$clang++-trunk test.cc
test.cc:1:16: warning: declaration does not declare anything
[-Wmissing-declarations]
template<class>;               ^
1 warning generated.


But in gcc, icc, or msvc, they all fail to compile it.

For example, in gcc

$g++ test.cc
test.cc:1:16: error: expected unqualified-id before ‘;’ token
    1 | template<class>;
      |        
        ^
I also tested in other released clang versions, they all accepts test.cc.

-- 
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/20200607/b62672c8/attachment.html>


More information about the llvm-bugs mailing list