https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111247
Bug ID: 111247
Summary: Very confusing diagnostic when attempting to
initialize an incomplete type: "too many initializers"
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: chgros at synopsys dot com
Target Milestone: ---
Compiling this code with g++ 12 gives a very misleading diagnostic when
attempting to initialize an incomplete type:
class Incomplete;
void use(Incomplete &&);
void bad()
{
use(Incomplete{0, 2});
}
error: too many initializers for 'Incomplete'
7 | use(Incomplete{0, 2});
It took me a while to figure out I was missing a header.