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

            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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

My clang is 9.0.0, and the code is:

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


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

msvc:

<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
union

Compiler returned: 2

icc:

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

   unsigned long __ptr;

   ^

compilation aborted for <source> (code 4)

Compiler returned: 4

gcc:

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

x86-64 gcc (trunk)
1
<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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to