Repository navigation
Always inline dyn_array_iterator constructor on AArch64 - #1280
Conversation
60be9bd to
2c32b47
Compare
|
Repro on Compiler Explorer: https://godbolt.org/z/dav8ToW3v Is there a reason to go the attribute route instead of the diagnostic suppression route? I don't think I have a preference either way, just curious if you considered it. |
|
I suppose a variant with #pragma to suppress the diagnostic may be too broad and ignore valid warnings if any. The second question is where to put these pragmas? In --- a/tests/dyn_array_tests.cpp
+++ b/tests/dyn_array_tests.cpp
@@ -156,8 +156,12 @@ TEST(dyn_array_tests, range_for)
TEST(dyn_array_tests, use_std_algorithms)
{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
gsl::dyn_array<char> dodgers(26);
std::generate(dodgers.begin(), dodgers.end(), [i = 0]() mutable { return 'a' + i++; });
+#pragma GCC diagnostic pop
+
char ch = 'a';
for (auto x : dodgers) EXPECT_EQ(x, ch++);
EXPECT_EQ(std::find(dodgers.begin(), dodgers.end(), 'a'), dodgers.begin());This hides the warning, but only in the test suite and does not help users who might stumble into this issue in their code in large translation units. I searched through IPA dumps taken with the |
Carson Radtke (carsonRadtke)
left a comment
There was a problem hiding this comment.
LGTM. Thanks!
a22ab8a
into
microsoft:main
Alas, I am still hit by that -Wstringop-overflow warning on AArch64 even in version 5.0.1. The warning appears depending on size of the translation unit, and it is not easy to prepare a minimal reproducible example. However, you can use the following to verify that the error exists in the main branch and that the proposed patch fixes it.
commands to reproduce
git checkout v5.0.1 docker run --rm -it -v $(pwd):/src/gsl -w /src/gsl debian:unstabledpkg --add-architecture arm64 apt-get update apt-get install -y --no-install-recommends g++-16-aarch64-linux-gnu pkgconf:arm64 libgtest-dev:arm64 cmake make cmake -B build -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON -DPKG_CONFIG_EXECUTABLE=/usr/bin/aarch64-linux-gnu-pkgconf -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++-16 -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_CXX_FLAGS=-std=c++20 -DGSL_CXX_STANDARD=20 make -C build -j$(nproc) dyn_array_testsThere are similar commands in my issue comment, but here I install pkgconf:arm64 and libgtest-dev:arm64 instead of ca-certificates and git. In Debian, we run CI tests without Internet access, and we are forced to use the packaged Google Test not downloading with Git.
I suggest adding a hint for early inliner in GCC, and thus working around the compiler bug.
Fixes: #1275
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108912