| Summary: | GCC 6 bogus narrowing conversion warning | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Andy Lutomirski <luto> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | rawhide | CC: | davejohansen, jakub, jwakely, law, mpolacek |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2016-02-04 20:00:04 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
As explained at https://gcc.gnu.org/gcc-6/porting_to.html the default -std option is different in GCC 6. This code fails with GCC 5 as well if you use -std=c++11, so it's a C++98 vs C++11 difference, not a GCC 5 vs GCC 6 difference. (In reply to Andy Lutomirski from comment #0) > fish_tests.cpp:1148:57: error: narrowing conversion of '-2' from 'int' to > 'wchar_t' inside { } [-Wnarrowing] > wchar_t wb[] = {-2, 0xa, (wchar_t)0xffffffff, 0x0441}; > ^ > This seems bogus to me. > > First, it only warns at all on arm. That's odd. Signed vs unsigned wchar_t I assume. > Second, if I build this on Fedora 23: > > #include <stddef.h> > > unsigned short wb[] = {-2, 0xa, (unsigned short)0xffffffff, 0x0441}; > unsigned short bad[] = {-2, 0xa, 0xffffffff, 0x0441}; > > I get: > > narrowing.c:5:34: warning: large integer implicitly truncated to unsigned > type [-Woverflow] > unsigned short bad[] = {-2, 0xa, 0xffffffff, 0x0441}; > > GCC 5.3.1 has it right: the implicit conversion is bad, but I think the > explicit conversion should be fine. It's not complaining about the explicit conversion, it's complaining about the -2, which the C++11 standard says is ill-formed. Oh, right. That makes considerably more sense. That'll teach me to read errors more carefully. |
fish is failing to build from source on rawhide because: g++ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -fno-exceptions -Wall -Wno-sign-compare -D_GNU_SOURCE=1 -D_ISO99_SOURCE=1 -DLOCALEDIR=\"/usr/share/locale\" -DPREFIX=L\"/usr\" -DDATADIR=L\"/usr/share\" -DSYSCONFDIR=L\"/etc\" -DBINDIR=L\"/usr/bin\" -DDOCDIR=L\"/usr/share/doc/fish\" -DFISH_BUILD_VERSION=\"2.2.0\" -c -o fish_tests.o fish_tests.cpp fish_tests.cpp: In function 'void test_utf8()': fish_tests.cpp:1148:57: error: narrowing conversion of '-2' from 'int' to 'wchar_t' inside { } [-Wnarrowing] wchar_t wb[] = {-2, 0xa, (wchar_t)0xffffffff, 0x0441}; ^ This seems bogus to me. First, it only warns at all on arm. That's odd. Second, if I build this on Fedora 23: #include <stddef.h> unsigned short wb[] = {-2, 0xa, (unsigned short)0xffffffff, 0x0441}; unsigned short bad[] = {-2, 0xa, 0xffffffff, 0x0441}; I get: narrowing.c:5:34: warning: large integer implicitly truncated to unsigned type [-Woverflow] unsigned short bad[] = {-2, 0xa, 0xffffffff, 0x0441}; GCC 5.3.1 has it right: the implicit conversion is bad, but I think the explicit conversion should be fine.