mirror of
https://github.com/boostorg/optional.git
synced 2025-07-16 13:52:08 +02:00
Config: detect ref convert bug in gcc 4.4 and 4.5
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2014 Andrzej Krzemienski.
|
||||
// Copyright (C) 2014, 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2014 Andrzej Krzemienski.
|
||||
// Copyright (C) 2014, 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
|
@ -82,4 +82,18 @@
|
||||
|
||||
#endif // defined(__GNUC__)
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// On some initial rvalue reference implementations GCC does it in a strange way,
|
||||
// preferring perfect-forwarding constructor to implicit copy constructor.
|
||||
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
|
||||
# define BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT
|
||||
# endif
|
||||
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ == 5)
|
||||
# define BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT
|
||||
# endif
|
||||
|
||||
#endif // defined(__GNUC__)
|
||||
|
||||
#endif // header guard
|
||||
|
@ -64,6 +64,8 @@ import testing ;
|
||||
[ run-fail optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp ]
|
||||
[ run optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_pass.cpp ]
|
||||
[ run-fail optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_fail.cpp ]
|
||||
[ run optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_pass.cpp ]
|
||||
[ compile-fail optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_fail.cpp ]
|
||||
[ run optional_xconfig_HACK_TO_LIST_PREDEFINED_MACROS.cpp ]
|
||||
;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
int main()
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
int empty = 0;
|
||||
int empty = -1;
|
||||
BOOST_TEST_EQ(empty, __GNUC__);
|
||||
BOOST_TEST_EQ(empty, __GNUC_MINOR__);
|
||||
BOOST_TEST_EQ(empty, __GNUC_PATCHLEVEL__);
|
||||
|
37
test/optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_fail.cpp
Normal file
37
test/optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_fail.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/ignore_unused.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/detail/optional_config.hpp"
|
||||
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_NO_LEGAL_CONVERT_FROM_REF
|
||||
|
||||
static_assert(false, "failed as requested");
|
||||
|
||||
#else
|
||||
|
||||
struct S {};
|
||||
|
||||
struct Binder
|
||||
{
|
||||
S& ref_;
|
||||
template <typename R> Binder (R&&r) : ref_(r) {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
S s ;
|
||||
Binder b = s;
|
||||
boost::ignore_unused(b);
|
||||
}
|
||||
|
||||
#endif
|
41
test/optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_pass.cpp
Normal file
41
test/optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_pass.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/ignore_unused.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/detail/optional_config.hpp"
|
||||
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_NO_LEGAL_CONVERT_FROM_REF
|
||||
|
||||
struct S {};
|
||||
|
||||
struct Binder
|
||||
{
|
||||
S& ref_;
|
||||
template <typename R> Binder (R&&r) : ref_(r) {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
S s ;
|
||||
Binder b = s;
|
||||
boost::ignore_unused(b);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user