From: Jonathan Wakely Date: Tue, 1 Apr 2025 10:02:43 +0000 (+0100) Subject: libstdc++: Avoid bogus -Walloc-size-larger-than warning in test [PR116212] X-Git-Tag: releases/gcc-14.3.0~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30d7bca6c2a3d70ecafdc4b2cf807944c736214c;p=thirdparty%2Fgcc.git libstdc++: Avoid bogus -Walloc-size-larger-than warning in test [PR116212] The compiler can't tell that the vector size fits in int, so it thinks it might overflow to a negative value, which would then be a huge positive size_t. In reality, the vector size never exceeds five. There's no warning on trunk, so just change the local variable to use type unsigned so that we get rid of the warning on the branches. libstdc++-v3/ChangeLog: PR libstdc++/116212 * testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc: Use unsigned for vector size. --- diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc index 62f933137d26..a9f7bbf0eb71 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc @@ -50,7 +50,7 @@ test01(std::vector ix) { ix = saved_ix; - int size = ix.size(); + unsigned size = ix.size(); auto buffer = std::unique_ptr(new char[sizeof(T)*size]); std::span rx((T *)buffer.get(), size);