Error building iv with C++11 - -Wnarrowing

Post Reply
asinha2
Posts: 4
Joined: Thu Oct 09, 2014 10:46 am

Error building iv with C++11 - -Wnarrowing

Post by asinha2 »

Hey,

I was building iv from the latest mercurial checkout on Fedora 23 that runs gcc 5.3.1:

Code: Select all

[asinha@cs-as14aho-2-herts-ac-uk  ~]$ gcc --version
gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The default standard here is C++11, and this includes the -Wnarrowing flag in builds that causes the build to fail with the errors like this:

Code: Select all

 inside { } [-Wnarrowing]
    0xfe, 0x07, 0xfe, 0x03, 0xfc, 0x01, 0xf0, 0x00, 0x60, 0x00};
                                                              ^
../include/InterViews/Bitmaps/rmoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmoverMask.bm:7:62: error: narrowing conversion of '252' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmoverMask.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:50:0:
../include/InterViews/Bitmaps/rmover.bm:7:62: error: narrowing conversion of '158' from 'int' to 'char' inside { } [-Wnarrowing]
    0x02, 0x07, 0x9e, 0x03, 0xdc, 0x01, 0xf0, 0x00, 0x60, 0x00};
                                                              ^
../include/InterViews/Bitmaps/rmover.bm:7:62: error: narrowing conversion of '158' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmover.bm:7:62: error: narrowing conversion of '220' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/rmover.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:51:0:
../include/InterViews/Bitmaps/umoverHit.bm:7:62: error: narrowing conversion of '160' from 'int' to 'char' inside { } [-Wnarrowing]
    0x04, 0x04, 0x1c, 0x07, 0x10, 0x01, 0x10, 0x01, 0xf0, 0x01};
                                                              ^
../include/InterViews/Bitmaps/umoverHit.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:52:0:
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
    0xfe, 0x07, 0xf8, 0x07, 0xf8, 0x01, 0xf8, 0x01, 0xf0, 0x01};
                                                              ^
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '252' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umoverMask.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:53:0:
../include/InterViews/Bitmaps/umover.bm:7:62: error: narrowing conversion of '136' from 'int' to 'char' inside { } [-Wnarrowing]
    0x8e, 0x07, 0x88, 0x07, 0x88, 0x01, 0xf8, 0x01, 0xf0, 0x01};
                                                              ^
../include/InterViews/Bitmaps/umover.bm:7:62: error: narrowing conversion of '142' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umover.bm:7:62: error: narrowing conversion of '136' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umover.bm:7:62: error: narrowing conversion of '136' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umover.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/umover.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:54:0:
../include/InterViews/Bitmaps/dmoverHit.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
    0x04, 0x04, 0x08, 0x02, 0x10, 0x01, 0xa0, 0x00, 0x40, 0x00};
                                                              ^
../include/InterViews/Bitmaps/dmoverHit.bm:7:62: error: narrowing conversion of '160' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:55:0:
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
    0xfc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0x40, 0x00};
                                                              ^
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '254' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '252' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '240' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmoverMask.bm:7:62: error: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from IV-2_6/adjuster2_6.cpp:56:0:
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '248' from 'int' to 'char' inside { } [-Wnarrowing]
    0x04, 0x07, 0x88, 0x03, 0xd0, 0x01, 0xe0, 0x00, 0x40, 0x00};
                                                              ^
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '136' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '136' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '142' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '136' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '208' from 'int' to 'char' inside { } [-Wnarrowing]
../include/InterViews/Bitmaps/dmover.bm:7:62: error: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]
This is what the gcc manual says:

Code: Select all

-Wnarrowing (C++ and Objective-C++ only)
                Warn when a narrowing conversion prohibited by C++11 occurs within { }, e.g.

                        int i = { 2.2 }; // error: narrowing from double to int

                This flag is included in -Wall and -Wc++11-compat.

                With -std=c++11, -Wno-narrowing suppresses the diagnostic required by the standard.  Note that this does not affect the meaning of well-formed code; narrowing conversions are still considered ill-formed in SFINAE context.

I just thought I'd point it out - I'm going to try and build with c++98 now.
Cheers!
Post Reply