Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

failure to build on OpenIndiana g++14

Open ghost opened this issue 4 months ago • 2 comments

Describe the bug Build failure. Image

And link failure if replacing with std::isnan. Image

Expected behavior It building and linking properly.

Reproduction steps Steps to reproduce the bug.

  • install OpenIndiana/some illumos-based distro with this specific gcc version
  • sudo pkg install gcc-14
  • git clone --depth=1 https://github.com/catchorg/Catch2
  • cd Catch2
  • cmake -DCMAKE_BUILD_TYPE=Release -B build
  • cmake --build build -- -j128

Platform information:

  • OS: OpenIndiana
  • Compiler+version: GCC v14.3.0
  • Catch version: latest git

Additional context I solved the issue by replacing with std::isnan, but it didn't make the linker happy either, Replacing Catch::isnan for std::isnan in catch_tostring.cpp makes it compile and link just fine.

ghost avatar Aug 02 '25 22:08 ghost

Try different version of GCC I guess. This works on all platforms and compilers in our CI, and Catch::isnan symbol obviously exists in the relevant file.

Catch::isnan is declared in catch_polyfills.hpp:


//              Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
//   (See accompanying file LICENSE.txt or copy at
//        https://www.boost.org/LICENSE_1_0.txt)

// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_POLYFILLS_HPP_INCLUDED
#define CATCH_POLYFILLS_HPP_INCLUDED

namespace Catch {

    bool isnan(float f);
    bool isnan(double d);

    float nextafter(float x, float y);
    double nextafter(double x, double y);

}

#endif // CATCH_POLYFILLS_HPP_INCLUDED

and this is the start of catch_matchers_floating_point.cpp

#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/internal/catch_enforce.hpp>
---> #include <catch2/internal/catch_polyfills.hpp> <---
#include <catch2/internal/catch_to_string.hpp>
#include <catch2/catch_tostring.hpp>
#include <catch2/internal/catch_floating_point_helpers.hpp>

horenmar avatar Aug 03 '25 20:08 horenmar

Try different version of GCC I guess. This works on all platforms and compilers in our CI, and Catch::isnan symbol obviously exists in the relevant file.

Catch::isnan is declared in catch_polyfills.hpp:

// Copyright Catch2 Authors // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at // https://www.boost.org/LICENSE_1_0.txt)

// SPDX-License-Identifier: BSL-1.0 #ifndef CATCH_POLYFILLS_HPP_INCLUDED #define CATCH_POLYFILLS_HPP_INCLUDED

namespace Catch {

bool isnan(float f);
bool isnan(double d);

float nextafter(float x, float y);
double nextafter(double x, double y);

}

#endif // CATCH_POLYFILLS_HPP_INCLUDED

and this is the start of catch_matchers_floating_point.cpp

#include <catch2/matchers/catch_matchers_floating_point.hpp> #include <catch2/internal/catch_enforce.hpp> ---> #include <catch2/internal/catch_polyfills.hpp> <--- #include <catch2/internal/catch_to_string.hpp> #include <catch2/catch_tostring.hpp> #include <catch2/internal/catch_floating_point_helpers.hpp>

Putting the #include <catch2/internal/catch_polyfills.hpp> atop all includes fixed the issue

ghost avatar Aug 16 '25 10:08 ghost