failure to build on OpenIndiana g++14
Describe the bug
Build failure.
And link failure if replacing with std::isnan.
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-14git clone --depth=1 https://github.com/catchorg/Catch2cd Catch2cmake -DCMAKE_BUILD_TYPE=Release -B buildcmake --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.
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>
Try different version of GCC I guess. This works on all platforms and compilers in our CI, and
Catch::isnansymbol obviously exists in the relevant file.
Catch::isnanis declared incatch_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