Skip to content

Fix for buffer overflow in fp_traits.hpp on aarch64 / mingw #1348

Description

@joostn

Hi,

I'm targeting aarch64-w64-mingw32 (probably I'm the first to try) and get this error:

/home/joostn/devel/wxwprojects_ptgui13/build/windows_mingw/arm64/RelWithDebInfo/thirdparty/boost-boost-1.90.0-prefix/include/boost/math/special_functions/detail/fp_traits.hpp:452:9: error: 'memcpy' will always overflow; destination buffer has size 0, but size argument is 4 [-Werror,-Wfortify-source]
  452 |         std::memcpy(reinterpret_cast<unsigned char*>(&x) + offset_, &a, 4);
      |         ^
1 error generated.

In include/boost/math/special_functions/detail/fp_traits.hpp you have this:

#if defined(BOOST_NO_INT64_T) || defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)\
   || defined(BOOST_BORLANDC) || defined(__CODEGEAR__) || (defined(__APPLE__) && defined(__aarch64__)) || defined(_MSC_VER)

but AFAIK aarch64-w64-mingw32 also has 64 bit long double, so it should also take that path. This would fix it:

   || defined(BOOST_BORLANDC) || defined(__CODEGEAR__) || (defined(__APPLE__) && defined(__aarch64__)) || defined(_MSC_VER) || (defined(__MINGW32__) && defined(_WIN32))

I'm not sure if there are other places where this should be fixed, or if there are side effects, so I don't dare to submit a pull request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions