On Sunday, October 27, 2024 2:16:20 A.M. CDT Andrey Rakhmatullin wrote: > On Sat, Oct 26, 2024 at 04:29:17PM -0500, Steven Robbins wrote: > > Hello, > > > > On Saturday, October 26, 2024 2:20:05 P.M. CDT Andrey Rakhmatullin wrote: > > > Control: reassign -1 libgtest-dev 1.15.2-1 > > > Control: affects -1 libmsgsl-dev > > > > > > That macro in libgtest-dev indeed contains a switch statement without a > > > default label, reassigning. > > > > The code in question is test code written for libmsgsl-dev, that is > > compiled using options that produce an error if a switch statement lacks > > a default label. Is that correct? > > The code in question is the GTEST_DEATH_TEST_ macro defined in > /usr/include/gtest/internal/gtest-death-test-internal.h , test code > written for libmsgsl-dev just has EXPECT_DEATH() calls. > > The code is compiled like this: > /usr/bin/clang++ -isystem > /tmp/autopkgtest.lG90Bd/build.QNu/src/tests/googletest/googletest/include > -std=c++20 -stdlib=libc++ -O3 -DNDEBUG -fno-strict-aliasing -Wall > -Wcast-align -Wconversion -Wctor-dtor-privacy -Werror -Wextra -Wpedantic > -Wshadow -Wsign-conversion -Wno-deprecated-declarations -Weverything > -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-missing-braces > -Wno-covered-switch-default -Wno-global-constructors > -Wno-missing-prototypes -Wno-padded -Wno-unknown-attributes > -Wno-used-but-marked-unused -Wno-weak-vtables -Wno-unsafe-buffer-usage -MD > -MT CMakeFiles/gsl_tests.dir/string_span_tests.cpp.o -MF > CMakeFiles/gsl_tests.dir/string_span_tests.cpp.o.d -o > CMakeFiles/gsl_tests.dir/string_span_tests.cpp.o -c > /tmp/autopkgtest.lG90Bd/build.QNu/src/tests/string_span_tests.cpp so it > looks like -Wswitch-default is enabled by default in the compiler. > > I may be very wrong but to me it looks like the gtest macro needs changes.
I reproduced the issue using the attached source code. It compiles fine using the command "clang -c death-test.cc". It even compiles fine using "... -Werror -Wall -Wpedantic". It does fail using all the switches you cite above: $ clang -c death-test.cc -Wall -Wcast-align -Wconversion -Wctor-dtor-privacy -Werror -Wextra -Wpedantic -Wshadow -Wsign-conversion -Wno-deprecated- declarations -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno- missing-braces -Wno-covered-switch-default -Wno-global-constructors -Wno- missing-prototypes -Wno-padded -Wno-unknown-attributes -Wno-used-but-marked- unused -Wno-weak-vtables -Wno-unsafe-buffer-usage death-test.cc:21:5: error: 'switch' missing 'default' label [-Werror,-Wswitch- default] 21 | ASSERT_DEATH(ThisShouldDie(), ""); | ^ /usr/include/gtest/gtest-death-test.h:185:3: note: expanded from macro 'ASSERT_DEATH' 185 | ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher) | ^ /usr/include/gtest/gtest-death-test.h:174:3: note: expanded from macro 'ASSERT_EXIT' 174 | GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_) | ^ /usr/include/gtest/internal/gtest-death-test-internal.h:233:7: note: expanded from macro 'GTEST_DEATH_TEST_' 233 | switch (gtest_dt->AssumeRole()) { \ | ^ 1 error generated. Certainly it would be nice to have C++ code build clean with every variation of compiler switches. But does that rise to the level of a *release critical* bug? Is there a rule - written or unwritten - that leads one to that conclusion? Regards, -Steve
#include <gtest/gtest.h> class FooTest : public testing::Test { protected: void ThisShouldDie() { } }; using FooDeathTest = FooTest; TEST_F(FooTest, DoesThis) { // normal test } TEST_F(FooDeathTest, DoesThat) { ASSERT_DEATH(ThisShouldDie(), ""); }
signature.asc
Description: This is a digitally signed message part.