<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang treats differently on function return type with a union"
   href="https://bugs.llvm.org/show_bug.cgi?id=46645">46645</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang treats differently on function return type with a union
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>haoxintu@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi, all.

This code, test.cc, line 1 and 2  equals to line 3 (right?). Clang treats it
differently.

$cat test.cc
typedef union{} typedef_union;
typename :: typedef_union foo1 () {} 
union {} foo2 () {}

$clang++ -c -w test.cc
test.cc:3:1: error: '(anonymous union at test.cc:3:1)' cannot be defined in the
result type of a function
union {} foo2 () {}
^
1 error generated.

Clang rejects line 3 but accepts line 2. 

While in GCC
$g++ -c -w test.cc
test.cc:2:13: error: ‘class’ tag used in naming ‘union typedef_union’
[-fpermissive]
    2 | typename :: typedef_union foo1 () {}
      |             ^~~~~~~~~~~~~
test.cc:1:17: note: ‘union typedef_union’ was previously declared here
    1 | typedef union{} typedef_union;
      |                 ^~~~~~~~~~~~~
test.cc:3:1: error: new types may not be defined in a return type
    3 | union {} foo2 () {}
      | ^~~~~
test.cc:3:1: note: (perhaps a semicolon is missing after the definition of
‘<unnamed union>’)

GCC emits two errors in line 2 and line 3.

I guess Clang might treat the line 2 and line 3 equally. So is this a Clang's
accept-invalid bug or GCC's reject-valid? 

Thanks,
Haoxin</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>