mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 11:35:38 -04:00
[librptext/tests] TextFuncsTest: Work around the aggressive-loop-optimizations warning.
When compiling with LTO enabled on gcc-14.2.0 (e.g. with Ubuntu 25.04), the following warning (as error) appeared. Work around it by checking for str.empty() before resizing the string. [cmake] gcc.cmake: Remove -Wno-error=aggressive-loop-optimizations, since it's no longe needed. In function ‘assign’, inlined from ‘_S_assign’ at /usr/include/c++/14/bits/basic_string.h:455:23, inlined from ‘_S_assign’ at /usr/include/c++/14/bits/basic_string.h:450:7, inlined from ‘_M_replace_aux’ at /usr/include/c++/14/bits/basic_string.tcc:471:17, inlined from ‘append’ at /usr/include/c++/14/bits/basic_string.h:1499:30, inlined from ‘resize’ at /usr/include/c++/14/bits/basic_string.tcc:405:14, inlined from ‘resize’ at /usr/include/c++/14/bits/basic_string.h:1119:21, inlined from ‘TestBody’ at src/librptext/tests/TextFuncsTest.cpp:513:12: /usr/include/c++/14/bits/char_traits.h:837:25: error: iteration 9223372036854775807 invokes undefined behavior [-Werror=aggressive-loop-optimizations] 837 | assign(__s[__i], __a); | ^ /usr/include/c++/14/bits/char_traits.h:836:34: note: within this loop 836 | for (size_t __i = 0; __i < __n; ++__i) | ^ In function ‘assign’, inlined from ‘_S_assign’ at /usr/include/c++/14/bits/basic_string.h:455:23, inlined from ‘_S_assign’ at /usr/include/c++/14/bits/basic_string.h:450:7, inlined from ‘_M_replace_aux’ at /usr/include/c++/14/bits/basic_string.tcc:471:17, inlined from ‘append’ at /usr/include/c++/14/bits/basic_string.h:1499:30, inlined from ‘resize’ at /usr/include/c++/14/bits/basic_string.tcc:405:14, inlined from ‘resize’ at /usr/include/c++/14/bits/basic_string.h:1119:21, inlined from ‘TestBody’ at src/librptext/tests/TextFuncsTest.cpp:542:12: /usr/include/c++/14/bits/char_traits.h:837:25: error: iteration 9223372036854775807 invokes undefined behavior [-Werror=aggressive-loop-optimizations] 837 | assign(__s[__i], __a); | ^ /usr/include/c++/14/bits/char_traits.h:836:34: note: within this loop 836 | for (size_t __i = 0; __i < __n; ++__i) | ^ lto1: all warnings being treated as errors lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status compilation terminated.
This commit is contained in:
parent
3022868577
commit
28b649388d
@ -276,7 +276,7 @@ ENDIF(CFLAG_OPTIMIZE_FTREE_VECTORIZE)
|
||||
# Add "-Werror" *after* checking for everything else.
|
||||
SET(RP_C_FLAGS_COMMON "${RP_C_FLAGS_COMMON} -Werror")
|
||||
SET(RP_CXX_FLAGS_COMMON "${RP_CXX_FLAGS_COMMON} -Werror")
|
||||
SET(CFLAGS_WNO_ERROR -Wno-error=unknown-pragmas -Wno-error=address -Wno-error=attributes -Wno-error=unused-parameter -Wno-error=unused-but-set-variable -Wno-error=ignored-qualifiers -Wno-error=missing-field-initializers -Wno-error=unused-variable -Wno-error=unused-function -Wno-error=type-limits -Wno-error=empty-body -Wno-error=address-of-packed-member -Wno-error=shift-negative-value -Wno-error=clobbered -Wno-error=overloaded-virtual -Wno-error=header-hygiene -Wno-error=cast-align -Wno-error=stringop-overread -Wno-error=aggressive-loop-optimizations)
|
||||
SET(CFLAGS_WNO_ERROR -Wno-error=unknown-pragmas -Wno-error=address -Wno-error=attributes -Wno-error=unused-parameter -Wno-error=unused-but-set-variable -Wno-error=ignored-qualifiers -Wno-error=missing-field-initializers -Wno-error=unused-variable -Wno-error=unused-function -Wno-error=type-limits -Wno-error=empty-body -Wno-error=address-of-packed-member -Wno-error=shift-negative-value -Wno-error=clobbered -Wno-error=overloaded-virtual -Wno-error=header-hygiene -Wno-error=cast-align -Wno-error=stringop-overread)
|
||||
FOREACH(FLAG_TEST ${CFLAGS_WNO_ERROR})
|
||||
# CMake doesn't like certain characters in variable names.
|
||||
STRING(REGEX REPLACE "/|:|=" "_" FLAG_TEST_VARNAME "${FLAG_TEST}")
|
||||
|
@ -510,7 +510,11 @@ TEST_F(TextFuncsTest, utf16_bswap_BEtoLE)
|
||||
str = utf16_bswap(C16(utf16be_data), C16_ARRAY_SIZE_I(utf16be_data));
|
||||
EXPECT_EQ(C16_ARRAY_SIZE(utf16le_data), str.size());
|
||||
// Remove the extra NULL before comparing.
|
||||
str.resize(str.size()-1);
|
||||
// NOTE: The str.empty() check is required to fix an aggressive loop
|
||||
// optimization warning when compiling with LTO on gcc-14.2.0.
|
||||
if (!str.empty()) {
|
||||
str.resize(str.size()-1);
|
||||
}
|
||||
EXPECT_EQ(C16(utf16le_data), str);
|
||||
}
|
||||
|
||||
@ -539,7 +543,11 @@ TEST_F(TextFuncsTest, utf16_bswap_LEtoBE)
|
||||
str = utf16_bswap(C16(utf16le_data), C16_ARRAY_SIZE_I(utf16le_data));
|
||||
EXPECT_EQ(C16_ARRAY_SIZE(utf16be_data), str.size());
|
||||
// Remove the extra NULL before comparing.
|
||||
str.resize(str.size()-1);
|
||||
// NOTE: The str.empty() check is required to fix an aggressive loop
|
||||
// optimization warning when compiling with LTO on gcc-14.2.0.
|
||||
if (!str.empty()) {
|
||||
str.resize(str.size()-1);
|
||||
}
|
||||
EXPECT_EQ(C16(utf16be_data), str);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user