-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Description
When compiling libs/mpl/test/char.cpp on AIX with GCC 9.3, where "char" type is "unsigned char" by default, I have the following error:
"g++" -fvisibility-inlines-hidden -fPIC -maix32 -pthread -mcmodel=large -O3 -finline-functions -Wno-inline -Wall -fvisibility=hidden -O2 -ffp-contract=off
-ftls-model=initial-exec -DBOOST_ALL_NO_LIB=1 -DBOOST_BEAST_ALLOW_DEPRECATED -DBOOST_BEAST_SEPARATE_COMPILATION -DNDEBUG -I".." -c
-o "../bin.v2/libs/mpl/test/char.test/gcc-9/release/threading-multi/visibility-hidden/char.o" "../libs/mpl/test/char.cpp"
In file included from ../boost/mpl/aux_/test/assert.hpp:17,
from ../boost/mpl/aux_/test.hpp:19,
from ../libs/mpl/test/integral_wrapper_test.hpp:15,
from ../libs/mpl/test/char.cpp:17:
../libs/mpl/test/char.cpp: In function 'void test20()':
../libs/mpl/test/char.cpp:22:33: error: narrowing conversion of '-1' from 'int' to 'char' [-Wnarrowing]
22 | # define WRAPPER(T, i) char_< i >
| ^
Looking at details, the exact error is:
./libs/mpl/test/char.cpp.E.cpp: In function 'void test20()':
../libs/mpl/test/char.cpp.E.cpp:30698:162: error: narrowing conversion of '-1' from 'int' to 'char' [-Wnarrowing]
30698 | n_line_23 = sizeof( boost::mpl::assertion_failed<false>( boost::mpl::assert_arg( (void (*) ( is_same< prior< char_<0> >::type, char_<0 -1> > ))0, 1 ) ) ) }; }
where -1 is used for creating a char, which is "unsigned char" on AIX (and on other systems). Thus, creating a char with value -1 is forbidden.
I've already seen this issue on other tests of Boost.
The possible solutions are:
- manage "char" so that it works either with char="signed char" or with char="unsigned char". However, since the C/C++ says that the "char" type is "undefined", that depends on how each OS has implemented the details of the char type (like converting a negatif floating point value to an "unsigned" integer/char/short).
- replace "char" by "signed char" everywhere.
- do not use negative value
Second solution seems to be the more appropriate solution, since it will work everywhere. Unless using negative values is required.
Metadata
Metadata
Assignees
Labels
No labels