Opened 9 years ago

Closed 7 years ago

#9014 closed Bugs (fixed)

Warnings when compiling api_test_helpers.hpp

Reported by: gjasny@… Owned by: timblechmann
Milestone: To Be Determined Component: atomic
Version: Boost Release Branch Severity: Cosmetic
Keywords: Cc:

Description

Hello,

clang 3.3 warns about about the truncation of the larger constant:

clang-linux.compile.c++.without-pth ../../../bin.v2/libs/atomic/test/native_api.test/clang-linux-3.3/debug/threading-multi/native_api.o
In file included from native_api.cpp:12:
./api_test_helpers.hpp:268:35: warning: implicit conversion from 'int' to 'unsigned char' changes value from 32640 to 128 [-Wconstant-conversion]
    test_additive_wrap<T>(((T)-1) << (sizeof(T) * 8 - 1));
    ~~~~~~~~~~~~~~~~~~    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
native_api.cpp:20:5: note: in instantiation of function template specialization 'test_integral_api<unsigned char>' requested here
    test_integral_api<unsigned char>();
    ^
In file included from native_api.cpp:12:
./api_test_helpers.hpp:269:27: warning: implicit conversion from 'int' to 'unsigned char' changes value from -32641 to 127 [-Wconstant-conversion]
    test_additive_wrap<T>(~ (((T)-1) << (sizeof(T) * 8 - 1)));
    ~~~~~~~~~~~~~~~~~~    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./api_test_helpers.hpp:268:35: warning: implicit conversion from 'int' to 'unsigned short' changes value from 2147450880 to 32768 [-Wconstant-conversion]
    test_additive_wrap<T>(((T)-1) << (sizeof(T) * 8 - 1));
    ~~~~~~~~~~~~~~~~~~    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
native_api.cpp:24:5: note: in instantiation of function template specialization 'test_integral_api<unsigned short>' requested here
    test_integral_api<unsigned short>();
    ^
In file included from native_api.cpp:12:
./api_test_helpers.hpp:269:27: warning: implicit conversion from 'int' to 'unsigned short' changes value from -2147450881 to 32767 [-Wconstant-conversion]
    test_additive_wrap<T>(~ (((T)-1) << (sizeof(T) * 8 - 1)));
    ~~~~~~~~~~~~~~~~~~    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.

Thanks, Gregor

Change History (1)

comment:1 by Andrey Semashev, 7 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.