[llvm-bugs] [Bug 42212] New: Clang accepts invalid code

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 9 16:18:53 PDT 2019


            Bug ID: 42212
           Summary: Clang accepts invalid code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                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

My clang is 9.0.0, and the code is:

void f() {
 union {
 unsigned long __ptr;
 (int *)(0);

clang accepts the code, but icc, gcc and msvc all reject it.


<source>(5): error C2059: syntax error: '('

<source>(6): error C2143: syntax error: missing ')' before '{'

<source>(6): error C4430: missing type specifier - int assumed. Note: C++ does
not support default-int

<source>(9): warning C4183: 'typeof': missing return type; assumed to be a
member function returning 'int'

<source>(10): error C2059: syntax error: ')'

<source>(11): error C2059: syntax error: ')'

<source>(12): error C2238: unexpected token(s) preceding ';'

<source>(13): error C2627: 'typeof': member function not allowed in anonymous

Compiler returned: 2


<source>(7): internal error: bad pointer

   unsigned long __ptr;


compilation aborted for <source> (code 4)

Compiler returned: 4


    x86-64 gcc (trunk) (Editor #1, Compiler #1) C++

x86-64 gcc (trunk)
<Compilation failed>
No Results
x86-64 gcc (trunk)
- cached

    #1 with x86-64 gcc (trunk)

<source>: In function 'void f()':

<source>:5:2: error: statement-expressions are not allowed outside functions
nor in template-argument lists

    5 |  (

      |  ^

Compiler returned: 1

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/20190609/61ebbe2e/attachment-0001.html>

More information about the llvm-bugs mailing list