[Bug c++/78244] Narrowing conversion is accepted in a function template, but it should be rejected

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 26 19:46:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78244

--- Comment #12 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Another bit to extend the Comment 11 test:

// Test OVERLOAD in a template.
int id(int v) { return v; }
double id(double v) { return v; }

template <typename T>
auto f5(double v) -> decltype((S{id(v)}, 1)) { return 1; } // { dg-error
"narrowing conversion" }

template <typename T>
auto f6(int v) -> decltype((S{id(v)}, 1)) { return 1; }


More information about the Gcc-bugs mailing list