google / libkml

Reference implementation of OGC KML 2.2
Other
95 stars 55 forks source link

Several tests fail due to bool conversion in ASSERT_EQ with gcc 4.8/OSX 10.9 #2

Open shabble opened 10 years ago

shabble commented 10 years ago

Following a build, make check fails on compilation of 2 separate test files, src/kml/engine/clone_test.cc and src/kml/engine/merge_test.cc in the ASSERT_EQ(bool, other_bool) macro with an error of the form:

merge_test.cc:149:3: note: in expansion of macro 'ASSERT_EQ' ASSERT_EQ(kOpen, target_placemark_->get_open()); [...] merge_test.cc: [...] error: converting 'false' to pointer type for argument 1 of 'char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)' [-Werror=conversion-null]

See below for full error trace.

System info

uname -a:

Darwin chompy.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64 i386 MacBookPro8,2 Darwin

g++ --version:

g++ (MacPorts gcc48 4.8.2_0+universal) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Details

It seems like this might be a problem with googletest harness itself, there's an identical issue in the Chromium tracker #150812 which proposes a new ASSERT_BOOL_EQ to sidestep the conversion process. I also found a Chromium commit entry which worked around the problem by using ASSERT_TRUE(expected == tested) rather than ASSERT_EQ.

g++ -DHAVE_CONFIG_H -I. -I../../..  -I../../../src -I../../../third_party/boost_1_34_1 -I../../../third_party/gtest-1.7.0/include  -Wall -Wextra -Wno-unused-parameter -Werror -fno-rtti -DGTEST_HAS_RTTI=0 -g -O2 -MT merge_test-merge_test.o -MD -MP -MF .deps/merge_test-merge_test.Tpo -c -o merge_test-merge_test.o `test -f 'merge_test.cc' || echo './'`merge_test.cc
In file included from ../../../third_party/gtest-1.7.0/include/gtest/gtest.h:1929:0,
                 from merge_test.cc:34:
merge_test.cc: In member function 'virtual void kmlengine::MergeTest_TestMergeFieldsMany_Test::TestBody()':
../../../third_party/gtest-1.7.0/include/gtest/internal/gtest-internal.h:133:55: error: converting 'false' to pointer type for argument 1 of 'char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)' [-Werror=conversion-null]
     (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
                                                       ^
../../../third_party/gtest-1.7.0/include/gtest/gtest_pred_impl.h:77:52: note: in definition of macro 'GTEST_ASSERT_'
   if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                                    ^
../../../third_party/gtest-1.7.0/include/gtest/gtest_pred_impl.h:166:3: note: in expansion of macro 'GTEST_PRED_FORMAT2_'
   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
   ^
../../../third_party/gtest-1.7.0/include/gtest/gtest.h:1993:3: note: in expansion of macro 'ASSERT_PRED_FORMAT2'
   ASSERT_PRED_FORMAT2(::testing::internal:: \
   ^
../../../third_party/gtest-1.7.0/include/gtest/gtest.h:1994:32: note: in expansion of macro 'GTEST_IS_NULL_LITERAL_'
                       EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
                                ^
../../../third_party/gtest-1.7.0/include/gtest/gtest.h:2011:32: note: in expansion of macro 'GTEST_ASSERT_EQ'
 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                                ^
merge_test.cc:147:3: note: in expansion of macro 'ASSERT_EQ'
   ASSERT_EQ(kVisibility, target_placemark_->get_visibility());
   ^
../../../third_party/gtest-1.7.0/include/gtest/internal/gtest-internal.h:133:55: error: converting 'false' to pointer type for argument 1 of 'char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)' [-Werror=conversion-null]
     (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
                                                       ^
../../../third_party/gtest-1.7.0/include/gtest/gtest_pred_impl.h:77:52: note: in definition of macro 'GTEST_ASSERT_'
   if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                                    ^
../../../third_party/gtest-1.7.0/include/gtest/gtest_pred_impl.h:166:3: note: in expansion of macro 'GTEST_PRED_FORMAT2_'
   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
   ^
../../../third_party/gtest-1.7.0/include/gtest/gtest.h:1993:3: note: in expansion of macro 'ASSERT_PRED_FORMAT2'
   ASSERT_PRED_FORMAT2(::testing::internal:: \
   ^
../../../third_party/gtest-1.7.0/include/gtest/gtest.h:1994:32: note: in expansion of macro 'GTEST_IS_NULL_LITERAL_'
                       EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
                                ^
../../../third_party/gtest-1.7.0/include/gtest/gtest.h:2011:32: note: in expansion of macro 'GTEST_ASSERT_EQ'
 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                                ^
merge_test.cc:149:3: note: in expansion of macro 'ASSERT_EQ'
   ASSERT_EQ(kOpen, target_placemark_->get_open());
   ^

Workaround/Solution

As referenced above, using ASSERT_TRUE(foo==bar) is a practical workaround that I have employed and all tests subsequently pass. I'm not sure if it's better or worse than applying the ASSERT_BOOL_* patch to gtest though.

kiplingw commented 5 years ago

@shabble, this seems to only occur for me when building for i386, but not amd64. I see in the case of your build you were also attempting to build for i386. Is that correct? @dennisjenkins75.