libyami icon indicating copy to clipboard operation
libyami copied to clipboard

Integer overflow for 32bit build in gtest

Open kwizart opened this issue 6 years ago • 4 comments

Building current git on fedora 27 i686 and armv7hl with gtest fails with:


g++ -DHAVE_CONFIG_H -I. -I.. -I../interface -I../gtestsrc/gtest/include -g -O2 -Wall -Wno-unused-function -Wno-cpp -Wno-missing-braces -Werror -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 -m32 -march=i686 -mtune=generic -fasynchronous-unwind-tables -c -o unittest-utils_unittest.o test -f 'utils_unittest.cpp' || echo './'utils_unittest.cpp make[2]: Leaving directory '/builddir/build/BUILD/libyami-40fa32e79f12c3c85c360532be00b7e4f9a35920/common' utils_unittest.cpp: In member function 'virtual void UtilsTest_guessResolutionOverflow_Test::TestBody()': utils_unittest.cpp:134:54: error: integer overflow in expression [-Werror=overflow] sstream << long(std::numeric_limits::max()) * 2 + 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ utils_unittest.cpp:136:54: error: integer overflow in expression [-Werror=overflow] << long(std::numeric_limits::max()) * 3 + 2; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ cc1plus: all warnings being treated as errors

kwizart avatar Mar 08 '18 17:03 kwizart

@kwizart , thanks for reporting this, @wangzj0601 , could you help to check?

xuguangxin avatar Mar 14 '18 07:03 xuguangxin

@wangzj0601 ,any update on this?

xuguangxin avatar Mar 20 '18 14:03 xuguangxin

@xuguangxin, I am building the environment now.

wangzj0601 avatar Mar 21 '18 09:03 wangzj0601

OK, long and int are the same size on 32-bit compiler... thus, coercing the type to long long to clear the error and get the test to compile is not enough. The test will still fail when executed... and clearly it exposes another underlying flaw in the guessResolution function.

FYI, there are many more compiler errors on 32-bit builds beyond this (try enabling all encoders, decoders and debug and you'll see). Clearly, no one had 32-bit support in mind when developing this library.

uartie avatar Mar 23 '18 20:03 uartie