https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801
Bug ID: 65801
Summary: Allow -Wno-narrowing to silence stricter C++11
narrowing rules
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jengelh at inai dot de
This code:
---8<---
static struct zai { unsigned int x; } x = {-1};
--->8---
gives this error in C++11 mode:
$ g++-5 -std=gnu++11 -c y.cpp
y.cpp:1:46: error: narrowing conversion of ‘-1’ from ‘int’ to ‘unsigned int’
inside { }
Clang 3.5 offers using -Wno-narrowing to ignore this and continue with the
previous semantics of silently converting it, which is helpful if one's C++11
project has to include e.g. zend_API.h (which uses the -1 conversion).
Such a feature is missing from gcc.
$ gcc-5 -v
gcc version 5.0.1 20150416 (prerelease) [gcc-5-branch revision 222148] (SUSE
Linux)