This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/78244] New: Narrowing conversion is accepted in a function template, but it should be rejected
- From: "michele.caini at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 Nov 2016 23:20:54 +0000
- Subject: [Bug c++/78244] New: Narrowing conversion is accepted in a function template, but it should be rejected
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78244
Bug ID: 78244
Summary: Narrowing conversion is accepted in a function
template, but it should be rejected
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: michele.caini at gmail dot com
Target Milestone: ---
Consider the following code:
auto f() -> decltype(int{0.}, void()) { }
int main() { f(); }
It fails to compile with the following error:
> narrowing conversion of '0.0' from 'double' to 'int' inside { }
On the other side, the following function is accepted:
template <typename T>
auto f(T) -> decltype(int{0.}, void()) { }
int main(){
f(0);
}
Narrowing conversion still present.