Skip to content

Commit

Permalink
Update to boost 1.83 and be sure we compile in gcc13.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Dec 13, 2023
1 parent 3c87bc3 commit 423b858
Show file tree
Hide file tree
Showing 278 changed files with 24,118 additions and 8,510 deletions.
7 changes: 5 additions & 2 deletions CHANGES.rst
Expand Up @@ -2,10 +2,13 @@
Changes
=========

4.0.1 (unreleased)
4.1.0 (unreleased)
==================

- Nothing changed yet.
- Update the bundled version of the Boost libraries from 1.75 to 1.83
to support newer compilers like GCC 13.
- Compile in C++ 11 mode instead of whatever the compiler default was
(sometimes C++ 03), because the latter is deprecated by Boost.


4.0.0 (2023-12-11)
Expand Down
8 changes: 8 additions & 0 deletions include/README.rst
Expand Up @@ -31,3 +31,11 @@ A one liner to update from a boost distribution unpacked beside this
boost/ directory::

for i in `find . -type f`; do gcp -f ../boost_1_75_0/boost/${i:2} $i; done

1.83
====

In December 2023, this was updated to boost 1.83 to fix compilation
problems with gcc13, using a similar one-liner::

for i in `find . -type f`; do gcp -f ../boost_1_83_0/boost/${i:2} $i; done
141 changes: 120 additions & 21 deletions include/boost/assert/source_location.hpp
@@ -1,16 +1,24 @@
#ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED
#define BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED

// http://www.boost.org/libs/assert
// http://www.boost.org/libs/assert
//
// Copyright 2019 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// Copyright 2019, 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt

#include <boost/current_function.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/cstdint.hpp>
#include <iosfwd>
#include <string>
#include <cstdio>
#include <cstring>

#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L
# include <source_location>
#endif

namespace boost
{
Expand All @@ -26,14 +34,22 @@ struct source_location

public:

BOOST_CONSTEXPR source_location() BOOST_NOEXCEPT: file_( "(unknown)" ), function_( "(unknown)" ), line_( 0 ), column_( 0 )
BOOST_CONSTEXPR source_location() BOOST_NOEXCEPT: file_( "" ), function_( "" ), line_( 0 ), column_( 0 )
{
}

BOOST_CONSTEXPR source_location( char const * file, boost::uint_least32_t ln, char const * function, boost::uint_least32_t col = 0 ) BOOST_NOEXCEPT: file_( file ), function_( function ), line_( ln ), column_( col )
{
}

#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L

BOOST_CONSTEXPR source_location( std::source_location const& loc ) BOOST_NOEXCEPT: file_( loc.file_name() ), function_( loc.function_name() ), line_( loc.line() ), column_( loc.column() )
{
}

#endif

BOOST_CONSTEXPR char const * file_name() const BOOST_NOEXCEPT
{
return file_;
Expand All @@ -53,40 +69,123 @@ struct source_location
{
return column_;
}
};

template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ostream<E, T> & os, source_location const & loc )
{
os.width( 0 );
#if defined(BOOST_MSVC)
# pragma warning( push )
# pragma warning( disable: 4996 )
#endif

if( loc.line() == 0 )
{
os << "(unknown source location)";
}
else
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
# define BOOST_ASSERT_SNPRINTF(buffer, format, arg) std::sprintf(buffer, format, arg)
#else
# define BOOST_ASSERT_SNPRINTF(buffer, format, arg) std::snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), format, arg)
#endif

std::string to_string() const
{
os << loc.file_name() << ':' << loc.line();
unsigned long ln = line();

if( ln == 0 )
{
return "(unknown source location)";
}

std::string r = file_name();

char buffer[ 16 ];

BOOST_ASSERT_SNPRINTF( buffer, ":%lu", ln );
r += buffer;

unsigned long co = column();

if( co )
{
BOOST_ASSERT_SNPRINTF( buffer, ":%lu", co );
r += buffer;
}

char const* fn = function_name();

if( loc.column() )
if( *fn != 0 )
{
os << ':' << loc.column();
r += " in function '";
r += fn;
r += '\'';
}

os << ": in function '" << loc.function_name() << '\'';
return r;
}

#undef BOOST_ASSERT_SNPRINTF

#if defined(BOOST_MSVC)
# pragma warning( pop )
#endif

inline friend bool operator==( source_location const& s1, source_location const& s2 ) BOOST_NOEXCEPT
{
return std::strcmp( s1.file_, s2.file_ ) == 0 && std::strcmp( s1.function_, s2.function_ ) == 0 && s1.line_ == s2.line_ && s1.column_ == s2.column_;
}

inline friend bool operator!=( source_location const& s1, source_location const& s2 ) BOOST_NOEXCEPT
{
return !( s1 == s2 );
}
};

template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ostream<E, T> & os, source_location const & loc )
{
os << loc.to_string();
return os;
}

} // namespace boost

#if defined( BOOST_DISABLE_CURRENT_LOCATION )
#if defined(BOOST_DISABLE_CURRENT_LOCATION)

# define BOOST_CURRENT_LOCATION ::boost::source_location()

#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926

// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce
// the correct result under 19.31, so prefer the built-ins
# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN())

#elif defined(BOOST_MSVC)

// __LINE__ is not a constant expression under /ZI (edit and continue) for 1925 and before

# define BOOST_CURRENT_LOCATION_IMPL_1(x) BOOST_CURRENT_LOCATION_IMPL_2(x)
# define BOOST_CURRENT_LOCATION_IMPL_2(x) (x##0 / 10)

# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "")

#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && !defined(__NVCC__)

// Under nvcc, __builtin_source_location is not constexpr
// https://github.com/boostorg/assert/issues/32

# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current())

#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000

# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN())

#elif defined(BOOST_GCC) && BOOST_GCC >= 70000

// The built-ins are available in 4.8+, but are not constant expressions until 7
# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION())

#elif defined(BOOST_GCC) && BOOST_GCC >= 50000

# define BOOST_CURRENT_LOCATION ::boost::source_location()
// __PRETTY_FUNCTION__ is allowed outside functions under GCC, but 4.x suffers from codegen bugs
# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, __PRETTY_FUNCTION__)

#else

# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
// __func__ macros aren't allowed outside functions, but BOOST_CURRENT_LOCATION is
# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, "")

#endif

Expand Down

0 comments on commit 423b858

Please sign in to comment.