https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93710
Bug ID: 93710
Summary: poor location in diagnostics of messages about array
initializers
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
With one exception, the warnings for the invalid array initializers are not
associated with their location: they all point to the closing brace of the
initializer-list. When the list consists of many elements that can make it
quite difficult to understand which among them is causing the problem.
$ cat u.C && gcc -S -Wall -Wextra -Wpedantic u.C
struct A { A (int); A (char*); int i; };
int x;
A a1[] = {
0L,
&x, // accurate location
sizeof (A),
__builtin_offsetof (A, i)
};
u.C:10:1: error: conversion from ‘long int’ to ‘A’ is ambiguous
10 | };
| ^
u.C:1:21: note: candidate: ‘A::A(char*)’
1 | struct A { A (int); A (char*); int i; };
| ^
u.C:1:12: note: candidate: ‘A::A(int)’
1 | struct A { A (int); A (char*); int i; };
| ^
u.C:7:3: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
7 | &x, // accurate location
| ^~
| |
| int*
u.C:1:15: note: initializing argument 1 of ‘A::A(int)’
1 | struct A { A (int); A (char*); int i; };
| ^~~
u.C:10:1: error: conversion from ‘long unsigned int’ to ‘A’ is ambiguous
10 | };
| ^
u.C:1:21: note: candidate: ‘A::A(char*)’
1 | struct A { A (int); A (char*); int i; };
| ^
u.C:1:12: note: candidate: ‘A::A(int)’
1 | struct A { A (int); A (char*); int i; };
| ^