This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50011] New: [C++0x] warning: narrowing conversion of 'i' from 'short unsigned int' to 'int' inside { } [-Wnarrowing]
- From: "zsojka at seznam dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 7 Aug 2011 11:09:43 +0000
- Subject: [Bug c++/50011] New: [C++0x] warning: narrowing conversion of 'i' from 'short unsigned int' to 'int' inside { } [-Wnarrowing]
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50011
Summary: [C++0x] warning: narrowing conversion of 'i' from
'short unsigned int' to 'int' inside { } [-Wnarrowing]
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: zsojka@seznam.cz
CC: jason@gcc.gnu.org
Since fixing PR49577, gcc gives a warning for the following code:
void foo(short unsigned i)
{
int a[] = {i};
}
$ g++ -std=gnu++0x tst.C
tst.C: In function 'int foo(short unsigned int)':
tst.C:3:14: warning: narrowing conversion of 'i' from 'short unsigned int' to
'int' inside { } [-Wnarrowing]
8.5.4/6 says:
A narrowing conversion is an implicit conversion
...
â from an integer type or unscoped enumeration type to an integer type that
cannot represent all the values of the original type
...
In this case, 'int' can represent all the values of 'short unsigned int', so
unless I am missing something, this should be valid.