[Bug c++/89622] New: G++ prints notes, but no warning or error
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 7 13:35:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89622
Bug ID: 89622
Summary: G++ prints notes, but no warning or error
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
The following code compiles successfuly, but prints two mysterious notes:
# 1 "ambig.cc"
# 1 "ambig.h" 1
# 2 "ambig.h" 3
# 3 "ambig.h" 3
template<typename T>
struct X
{
X() { }
template<typename U> X(int, U&&) { }
template<typename U> X(char, const X<U>&) { }
};
template<typename T>
X<T> wrap_X(X<T> x)
{
return X<T>('a', x);
}
# 2 "ambig.cc" 2
# 3 "ambig.cc"
int main()
{
X<void> x;
wrap_X(x);
}
$ g++ ambig.ii
In file included from ambig.cc:1:
ambig.h: In instantiation of 'X<T> wrap_X(X<T>) [with T = void]':
ambig.cc:6:11: required from here
ambig.h:8:24: note: candidate 1: 'X<T>::X(char, const X<U>&) [with U = void; T
= void]'
ambig.h:7:24: note: candidate 2: 'X<T>::X(int, U&&) [with U = X<void>&; T =
void]'
Adding -Wsystem-headers reveals that the notes are related to a warning that is
suppressed:
ambig.h: In instantiation of 'X<T> wrap_X(X<T>) [with T = void]':
ambig.cc:6:11: required from here
ambig.h:14:10: warning: ISO C++ says that these are ambiguous, even though the
worst conversion for the first is better than the worst conversion for the
second:
ambig.h:8:24: note: candidate 1: 'X<T>::X(char, const X<U>&) [with U = void; T
= void]'
ambig.h:7:24: note: candidate 2: 'X<T>::X(int, U&&) [with U = X<void>&; T =
void]'
If the warning is suppressed then the notes should be too.
I get the same behaviour back to 4.3 so this doesn't seem to be a regression.
More information about the Gcc-bugs
mailing list