[llvm-bugs] [Bug 46440] New: Misleading error message "unions cannot have base classes"

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 24 07:50:14 PDT 2020


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

            Bug ID: 46440
           Summary: Misleading error message "unions cannot have base
                    classes"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

$cat bug.cc
class A1 {};
class A2 {};
class A3 {};
union : A1, A2, A3 {} u;

$clang++ -c bug.cc
bug.cc:4:1: error: unions cannot have base classes
union : A1, A2, A3 {} u;
^       ~~
bug.cc:4:1: error: unions cannot have base classes
union : A1, A2, A3 {} u;
^           ~~
bug.cc:4:1: error: unions cannot have base classes
union : A1, A2, A3 {} u;
^               ~~
3 errors generated.

In GCC
$g++ -c bug.cc
bug.cc:4:17: error: derived union ‘<unnamed union>’ invalid
    4 | union : A1, A2, A3 {} u;
      |                 ^~

I doubt that how clang deal with this case. I guess there are two situations:
1. Clang gives the wrong column number
2. Clang duplicates the error message

According to the marking "~~" in error messages, I guess clang might have the
first issue?

Also, I have tested it in almost all clang versions, they all have this issue.

-- 
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/20200624/10ac3f1c/attachment.html>


More information about the llvm-bugs mailing list