https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89894
Bug ID: 89894
Summary: poor error message when redefining a function
overloaded on a non-type specialization
Product: gcc
Version: 9.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: ---
The error message below make it difficult to understand what exactly the root
cause problem is: the names of the types of the arguments are different and no
other detail is provided. If the definitions of T and U and far apart (e.g.,
in different headers perhaps even supplied by different libraries) and
complicated (e.g., the result of some non-trivial algorithm) determining what
makes the types the same could be a non-trivial exercise.
Including a note in the error message pointing to the types underlying the
aliases would help.
Providing more detail about the underlying types, such as the values of the
constants the underlying templates are instantiated on analogously to what's
done for ordinary templates, would help even more.
$ cat z.C && gcc -c -Wall -std=c++2a z.C
struct A { int i; };
template <A> struct B { };
constexpr A f () { return A{1<<27}; }
constexpr A g () { return A{134217728}; }
typedef B<f ()> T;
typedef B<g ()> U;
void h (T) { }
void h (U) { }
z.C:10:6: error: redefinition of ‘void h(U)’
10 | void h (U) { }
| ^
z.C:9:6: note: ‘void h(T)’ previously defined here
9 | void h (T) { }
| ^