[Bug c++/95875] New: Misleading error message "invalid use of incomplete type"
haoxintu at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 24 16:29:41 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95875
Bug ID: 95875
Summary: Misleading error message "invalid use of incomplete
type"
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
Target Milestone: ---
$cat bug.cc
class A:
public
A,
A,
A
{} g_class;
$g++ -c bug.cc
bug.cc:5:1: error: invalid use of incomplete type ‘class A’
5 | A
| ^
bug.cc:1:7: note: forward declaration of ‘class A’
1 | class A:
| ^
bug.cc:5:1: error: invalid use of incomplete type ‘class A’
5 | A
| ^
bug.cc:1:7: note: forward declaration of ‘class A’
1 | class A:
| ^
bug.cc:5:1: error: invalid use of incomplete type ‘class A’
5 | A
| ^
bug.cc:1:7: note: forward declaration of ‘class A’
1 | class A:
| ^
While in clang
$clang++ -c bug.cc
bug.cc:3:1: error: base class has incomplete type
A,
^
bug.cc:1:7: note: definition of 'A' is not complete until the closing '}'
class A:
^
1 error generated.
I doubt that how GCC deals with this case. I guess there might be two
situations:
1. GCC gives the wrong line number.
2. GCC just emits the duplicated messages.
I guess GCC might have the second issue. I have tested in almost all GCC
versions, and they all have this issue.
More information about the Gcc-bugs
mailing list