Config: detect ref convert bug in gcc 4.4 and 4.5

This commit is contained in:
Andrzej Krzemienski
2015-10-14 23:11:33 +02:00
parent 29975d6192
commit fb1cf2581e
7 changed files with 97 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ]
;
}

View File

@ -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__);

View 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

View 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