[llvm-bugs] [Bug 46645] Clang treats differently on function return type with a union

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 9 17:14:43 PDT 2020


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

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
> This code, test.cc, line 1 and 2 equals to line 3 (right?).

They're approximately the same, but not entirely the same. The C++ rules don't
permit a type definition to appear in a return type, so line 3 is invalid, as
Clang and GCC report.

> So is this a Clang's accept-invalid bug or GCC's reject-valid?

This is a GCC rejects-valid bug. There's nothing wrong with line 2, and GCC's
diagnostic says that "class" was used when naming the union, which is obviously
wrong -- the keyword "class" does not appear in your example at all.

Even weirder: GCC gives a different diagnostic if you replace 'typename' with
'class'!

-- 
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/20200710/356869ac/attachment.html>


More information about the llvm-bugs mailing list