[Boost-bugs] [Boost C++ Libraries] #3598: Patch for warnings in Boost.Test

Subject: [Boost-bugs] [Boost C++ Libraries] #3598: Patch for warnings in Boost.Test
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-11-08 13:17:35


#3598: Patch for warnings in Boost.Test
--------------------------+-------------------------------------------------
 Reporter: johnmaddock | Owner: rogeeff
     Type: Patches | Status: new
Milestone: Boost 1.41.0 | Component: test
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 Boost.Test emits a number of annoying warnings when compiled with MSVC and
 /W4 or with gcc and -Wall -pedantic -Wextra.

 Amoungst other things that makes it hard to make other libraries warning
 free, or to compile their test cases with warnings-as-errors.

 The attached patch fixes almost all of the warnings produced by
 Boost.Test: both when #including it, and when running it's own test cases.

 The warnings fixed are, for MSVC:

 {{{
 execution_monitor.cpp
 d:\data\boost\trunk\boost\test\impl\execution_monitor.ipp(1161) : warning
 C4701: potentially uninitialized local variable 'old_crt_hook' used
 unit_test_parameters.cpp
 d:\data\boost\trunk\boost/test/utils/runtime/config.hpp(90) : warning
 C4996: 'putenv': The POSIX name for this item is deprecated. Instead, use
 the ISO C++ conformant name: _putenv. See online help for details.
         C:\Program Files\Microsoft Visual Studio
 9.0\VC\INCLUDE\stdlib.h(864) : see declaration of 'putenv'
 d:\data\boost\trunk\boost/test/utils/runtime/env/environment.ipp(82) :
 warning C4996: 'getenv': This function or variable may be unsafe. Consider
 using _dupenv_s instead. To disable deprecation, use
 _CRT_SECURE_NO_WARNINGS. See online help for details.
         C:\Program Files\Microsoft Visual Studio
 9.0\VC\INCLUDE\stdlib.h(447) : see declaration of 'getenv'
 foreach_test.cpp
 }}}

 And from gcc:

 {{{
 gcc.compile.c++
 /home/john/bin/boost/bin.v2/libs/test/test/errors_handling_test.test/gcc-4.4.1/debug/errors_handling_test.o
 In file included from
 ../../../boost/test/output/compiler_log_formatter.hpp:20,
                  from errors_handling_test.cpp:26:
 ../../../boost/test/unit_test_log_formatter.hpp:106: warning: unused
 parameter 'explanation'
 In file included from ../../../libs/test/src/execution_monitor.cpp:16:
 ../../../boost/test/impl/execution_monitor.ipp: In destructor
 'boost::detail::signal_handler::~signal_handler()':
 ../../../boost/test/impl/execution_monitor.ipp:791: warning: missing
 initializer for member 'sigaltstack::ss_sp'
 ../../../boost/test/impl/execution_monitor.ipp:791: warning: missing
 initializer for member 'sigaltstack::ss_flags'
 ../../../boost/test/impl/execution_monitor.ipp:791: warning: missing
 initializer for member 'sigaltstack::ss_size'
 result_report_test.cpp: In function 'void very_bad_foo()':
 result_report_test.cpp:60: warning: unused variable 'lg'
 result_report_test.cpp: In member function 'void
 test_result_reports::test_method()':
 result_report_test.cpp:107: warning: unused variable 'G'
 test_tools_test.cpp:506: warning: unused parameter 'a'
 boost_check_equal_str.cpp: In member function 'void
 check_string_compare::test_method()':
 boost_check_equal_str.cpp:22: warning: deprecated conversion from string
 constant to 'char*'
 In file included from ../../../boost/test/predicate_result.hpp:21,
                  from ../../../boost/test/test_tools.hpp:19,
                  from ../../../boost/test/unit_test.hpp:19,
                  from basic_cstring_test.cpp:21:
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp: In member
 function 'size_t
 boost::unit_test::basic_cstring<CharT>::rfind(boost::unit_test::basic_cstring<CharT>)
 const [with CharT = wchar_t]':
 basic_cstring_test.cpp:423: instantiated from 'void
 find_test_impl(boost::type<CharT>*) [with CharT = wchar_t]'
 basic_cstring_test.cpp:406: instantiated from 'static void
 find_test::run(boost::type<CharT>*) [with TestType = wchar_t]'
 ../../../boost/test/unit_test_suite_impl.hpp:357: instantiated from
 'void
 boost::unit_test::ut_detail::test_case_template_invoker<TestCaseTemplate,
 TestType>::operator()() [with TestCaseTemplate = find_test, TestType =
 wchar_t]'
 ../../../boost/test/utils/callback.hpp:56: instantiated from
 'boost::unit_test::ut_detail::unused
 boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke(Functor&)
 [with Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test,
 wchar_t>]'
 ../../../boost/test/utils/callback.hpp:89: instantiated from 'R
 boost::unit_test::ut_detail::callback0_impl_t<R, Functor>::invoke() [with
 R = boost::unit_test::ut_detail::unused, Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test,
 wchar_t>]'
 basic_cstring_test.cpp:474: instantiated from here
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:551: warning:
 enumeral and non-enumeral type in conditional expression
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp: In member
 function 'size_t
 boost::unit_test::basic_cstring<CharT>::rfind(boost::unit_test::basic_cstring<CharT>)
 const [with CharT = unsigned char]':
 basic_cstring_test.cpp:423: instantiated from 'void
 find_test_impl(boost::type<CharT>*) [with CharT = unsigned char]'
 basic_cstring_test.cpp:406: instantiated from 'static void
 find_test::run(boost::type<CharT>*) [with TestType = unsigned char]'
 ../../../boost/test/unit_test_suite_impl.hpp:357: instantiated from
 'void
 boost::unit_test::ut_detail::test_case_template_invoker<TestCaseTemplate,
 TestType>::operator()() [with TestCaseTemplate = find_test, TestType =
 unsigned char]'
 ../../../boost/test/utils/callback.hpp:56: instantiated from
 'boost::unit_test::ut_detail::unused
 boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke(Functor&)
 [with Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test,
 unsigned char>]'
 ../../../boost/test/utils/callback.hpp:89: instantiated from 'R
 boost::unit_test::ut_detail::callback0_impl_t<R, Functor>::invoke() [with
 R = boost::unit_test::ut_detail::unused, Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test,
 unsigned char>]'
 basic_cstring_test.cpp:474: instantiated from here
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:551: warning:
 enumeral and non-enumeral type in conditional expression
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp: In member
 function 'size_t
 boost::unit_test::basic_cstring<CharT>::rfind(boost::unit_test::basic_cstring<CharT>)
 const [with CharT = char]':
 basic_cstring_test.cpp:423: instantiated from 'void
 find_test_impl(boost::type<CharT>*) [with CharT = char]'
 basic_cstring_test.cpp:406: instantiated from 'static void
 find_test::run(boost::type<CharT>*) [with TestType = char]'
 ../../../boost/test/unit_test_suite_impl.hpp:357: instantiated from
 'void
 boost::unit_test::ut_detail::test_case_template_invoker<TestCaseTemplate,
 TestType>::operator()() [with TestCaseTemplate = find_test, TestType =
 char]'
 ../../../boost/test/utils/callback.hpp:56: instantiated from
 'boost::unit_test::ut_detail::unused
 boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke(Functor&)
 [with Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, char>]'
 ../../../boost/test/utils/callback.hpp:89: instantiated from 'R
 boost::unit_test::ut_detail::callback0_impl_t<R, Functor>::invoke() [with
 R = boost::unit_test::ut_detail::unused, Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, char>]'
 basic_cstring_test.cpp:474: instantiated from here
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:551: warning:
 enumeral and non-enumeral type in conditional expression
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp: In member
 function 'size_t
 boost::unit_test::basic_cstring<CharT>::rfind(boost::unit_test::basic_cstring<CharT>)
 const [with CharT = const wchar_t]':
 basic_cstring_test.cpp:423: instantiated from 'void
 find_test_impl(boost::type<CharT>*) [with CharT = const wchar_t]'
 basic_cstring_test.cpp:406: instantiated from 'static void
 find_test::run(boost::type<CharT>*) [with TestType = const wchar_t]'
 ../../../boost/test/unit_test_suite_impl.hpp:357: instantiated from
 'void
 boost::unit_test::ut_detail::test_case_template_invoker<TestCaseTemplate,
 TestType>::operator()() [with TestCaseTemplate = find_test, TestType =
 const wchar_t]'
 ../../../boost/test/utils/callback.hpp:56: instantiated from
 'boost::unit_test::ut_detail::unused
 boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke(Functor&)
 [with Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, const
 wchar_t>]'
 ../../../boost/test/utils/callback.hpp:89: instantiated from 'R
 boost::unit_test::ut_detail::callback0_impl_t<R, Functor>::invoke() [with
 R = boost::unit_test::ut_detail::unused, Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, const
 wchar_t>]'
 basic_cstring_test.cpp:474: instantiated from here
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:551: warning:
 enumeral and non-enumeral type in conditional expression
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp: In member
 function 'size_t
 boost::unit_test::basic_cstring<CharT>::rfind(boost::unit_test::basic_cstring<CharT>)
 const [with CharT = const unsigned char]':
 basic_cstring_test.cpp:423: instantiated from 'void
 find_test_impl(boost::type<CharT>*) [with CharT = const unsigned char]'
 basic_cstring_test.cpp:406: instantiated from 'static void
 find_test::run(boost::type<CharT>*) [with TestType = const unsigned char]'
 ../../../boost/test/unit_test_suite_impl.hpp:357: instantiated from
 'void
 boost::unit_test::ut_detail::test_case_template_invoker<TestCaseTemplate,
 TestType>::operator()() [with TestCaseTemplate = find_test, TestType =
 const unsigned char]'
 ../../../boost/test/utils/callback.hpp:56: instantiated from
 'boost::unit_test::ut_detail::unused
 boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke(Functor&)
 [with Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, const
 unsigned char>]'
 ../../../boost/test/utils/callback.hpp:89: instantiated from 'R
 boost::unit_test::ut_detail::callback0_impl_t<R, Functor>::invoke() [with
 R = boost::unit_test::ut_detail::unused, Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, const
 unsigned char>]'
 basic_cstring_test.cpp:474: instantiated from here
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:551: warning:
 enumeral and non-enumeral type in conditional expression
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp: In member
 function 'size_t
 boost::unit_test::basic_cstring<CharT>::rfind(boost::unit_test::basic_cstring<CharT>)
 const [with CharT = const char]':
 basic_cstring_test.cpp:423: instantiated from 'void
 find_test_impl(boost::type<CharT>*) [with CharT = const char]'
 basic_cstring_test.cpp:406: instantiated from 'static void
 find_test::run(boost::type<CharT>*) [with TestType = const char]'
 ../../../boost/test/unit_test_suite_impl.hpp:357: instantiated from
 'void
 boost::unit_test::ut_detail::test_case_template_invoker<TestCaseTemplate,
 TestType>::operator()() [with TestCaseTemplate = find_test, TestType =
 const char]'
 ../../../boost/test/utils/callback.hpp:56: instantiated from
 'boost::unit_test::ut_detail::unused
 boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke(Functor&)
 [with Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, const
 char>]'
 ../../../boost/test/utils/callback.hpp:89: instantiated from 'R
 boost::unit_test::ut_detail::callback0_impl_t<R, Functor>::invoke() [with
 R = boost::unit_test::ut_detail::unused, Functor =
 boost::unit_test::ut_detail::test_case_template_invoker<find_test, const
 char>]'
 basic_cstring_test.cpp:474: instantiated from here
 ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:551: warning:
 enumeral and non-enumeral type in conditional expression

 }}}

 Warnings not fixed;

 {{{
 d:\data\boost\trunk\libs\test\test\foreach_test.cpp(82) : warning C4702:
 unreachable code
 test_tree_management_test.cpp: In member function 'void
 manual_test_case_creation_test::test_method()':
 test_tree_management_test.cpp:109: warning: value computed is not used

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3598>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC