Compare commits

...

7 Commits

Author SHA1 Message Date
Peter Dimov
53c084084d Use BOOST_TEST_TRAIT_SAME 2022-12-23 02:32:03 +02:00
Peter Dimov
c225007399 Update dependency list in cmake_subdir_test 2022-12-23 02:17:32 +02:00
Peter Dimov
4633220a9d Update ci.yml 2022-12-23 02:14:27 +02:00
Peter Dimov
16fca8368b Keep -Wmaybe-uninitialized disabled 2022-05-30 20:25:13 +03:00
Peter Dimov
4cf7c718b8 Merge branch 'gcc12-Wuninitialized' of https://github.com/jngrad/boost-function into feature/issue-42 2022-05-30 19:56:08 +03:00
Peter Dimov
389f886bc3 Add test for issue #42 2022-05-30 19:36:29 +03:00
Jean-Noël Grad
5b4e2797a2 Avoid -Wuninitialized warnings in GCC 12 2022-05-30 16:16:41 +02:00
6 changed files with 43 additions and 15 deletions

View File

@@ -126,7 +126,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
if: matrix.install
@@ -194,7 +194,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
@@ -236,7 +236,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
if: matrix.install
@@ -282,7 +282,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
if: matrix.install
@@ -338,7 +338,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
if: matrix.install

View File

@@ -906,6 +906,10 @@ namespace boost {
// This warning is technically correct, but we don't want to pay the price for initializing
// just to silence a warning: https://github.com/boostorg/function/issues/27
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# if (BOOST_GCC >= 120000)
// GCC 12 emits a different warning: https://github.com/boostorg/function/issues/42
# pragma GCC diagnostic ignored "-Wuninitialized"
# endif
# endif
std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
@@ -1004,6 +1008,10 @@ namespace boost {
// This warning is technically correct, but we don't want to pay the price for initializing
// just to silence a warning: https://github.com/boostorg/function/issues/27
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# if (BOOST_GCC >= 120000)
// GCC 12 emits a different warning: https://github.com/boostorg/function/issues/42
# pragma GCC diagnostic ignored "-Wuninitialized"
# endif
# endif
std::memcpy(this->functor.data, f.functor.data, sizeof(this->functor.data));
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)

View File

@@ -82,3 +82,5 @@ run test_return_function.cpp return_function/<cxxstd>14 : : : <link>shared $(che
run test_return_function.cpp return_function/<cxxstd>14 : : : <link>static $(check14) : return_function_static_14 ;
run quick.cpp ;
compile issue_42.cpp ;

View File

@@ -33,10 +33,8 @@ boost_add_subdir(typeof)
boost_add_subdir(static_assert)
boost_add_subdir(container_hash)
boost_add_subdir(smart_ptr)
boost_add_subdir(detail)
boost_add_subdir(move)
boost_add_subdir(predef)
boost_add_subdir(describe)
boost_add_subdir(mp11)
# --target check

21
test/issue_42.cpp Normal file
View File

@@ -0,0 +1,21 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// https://github.com/boostorg/function/issues/42
#include <boost/function.hpp>
struct F
{
int operator()( int x ) const { return -x; }
};
struct X
{
boost::function<int(int)> f_;
explicit X( boost::function<int(int)> f ): f_( f ) {}
};
F f2;
X x( f2 ); // -Wuninitialized under GCC 12

View File

@@ -8,7 +8,6 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/function.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct X
@@ -27,14 +26,14 @@ int main()
{
typedef boost::function<X(Y)> F1;
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<F1::result_type, X> ));
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<F1::argument_type, Y> ));
BOOST_TEST_TRAIT_SAME(F1::result_type, X);
BOOST_TEST_TRAIT_SAME(F1::argument_type, Y);
typedef boost::function<X(Y, Z)> F2;
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<F2::result_type, X> ));
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<F2::first_argument_type, Y> ));
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<F2::second_argument_type, Z> ));
BOOST_TEST_TRAIT_SAME(F2::result_type, X);
BOOST_TEST_TRAIT_SAME(F2::first_argument_type, Y);
BOOST_TEST_TRAIT_SAME(F2::second_argument_type, Z);
return boost::report_errors();
}