This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80601] New: spurious -Wconversion warning with explicit class template arguments
- From: "jens.maurer at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 03 May 2017 06:22:41 +0000
- Subject: [Bug c++/80601] New: spurious -Wconversion warning with explicit class template arguments
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80601
Bug ID: 80601
Summary: spurious -Wconversion warning with explicit class
template arguments
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jens.maurer at gmx dot net
Target Milestone: ---
The all-new gcc 7.1.0 has introduced a conversion warning in template
definition context when a value-dependent sizeof is used as a template argument
for a class template. (There is no warning for something like
"f<sizeof(T)>()".) Note that the program below has no instantiation of "g", and
I believe a -Wconversion warning should not trigger when a constant value is
used that fits the target type.
g++ -Wconversion -c x.cc
x.cc: In function ‘int g(T)’:
x.cc:7:11: warning: conversion to ‘unsigned int’ from ‘long unsigned int’ may
alter its value [-Wconversion]
S<sizeof(T)> s;
template<unsigned int N>
struct S { };
template<class T>
void g(T)
{
S<sizeof(T)> s;
}