https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88375
Bug ID: 88375
Summary: Vague source location for bad initialization
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Given this C++11 code:
enum struct a : int {
one, two
};
struct foo {
int e1, e2;
a e3;
} arr[] = {
{ 1, 2, a::one },
{ 3, a::two },
{ 4, 5, a::two }
};
g++ trunk emits the unhelpfully vague:
/tmp/test.cc:12:1: error: cannot convert ‘a’ to ‘int’ in initialization
12 | };
| ^
(via an "error", with input_location at the final close-paren)
whereas clang identifies where the problem is:
/tmp/test.cc:10:8: error: cannot initialize a member subobject of type 'int'
with an rvalue of type 'a'
{ 3, a::two },
^~~~~~
1 error generated.
Similar to e.g. PR 45963, but might well be a different underlying issue.