GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

libstdc++: Arrange for non-constant math_errhandling to SFINAE [PR126807]

libstdc++ now correctly uses SFINAE for non-constant math_errhandling macro on Darwin, fixing build failures.

This change addresses build failures in libstdc++‘s SIMD testcases on Darwin, where the math_errhandling macro resolves to a function rather than a constant. Previously, this caused issues because the macro was not substituted correctly in dependent clauses. By using the macro as a default template argument, the code now correctly employs SFINAE, allowing the affected testcases to build successfully.

In Details

PR126807 highlighted that several SIMD testcases in libstdc++ fail to build on Darwin due to the math_errhandling macro being used in a non-dependent requires clause. On Darwin, math_errhandling is a macro that expands to a function call, not a compile-time constant. This prevents SFINAE from working as expected. This commit modifies simd_details.h to define math_errhandling as a default template argument, ensuring that template substitutions involving it are handled correctly by SFINAE, thus resolving the build failures.

For Context
libstdc++
The C++ standard library implementation used by GCC. It provides fundamental C++ functionalities like containers, algorithms, and I/O streams.
SFINAE
Substitution Failure Is Not An Error. A C++ template metaprogramming technique where a failing template substitution is treated as a valid overload resolution path, allowing for compile-time selection of functions or classes based on type properties.
math_errhandling
A C macro defined in <math.h> that indicates support for, and the manner of, reporting math errors. Its value can vary between implementations.
Darwin
The name of Apple's Unix-like operating system, serving as the foundation for macOS, iOS, and other Apple platforms. GCC builds for these platforms use Darwin-specific configurations.
SIMD
Single Instruction, Multiple Data. A type of parallel processing where a single instruction operates on multiple data points simultaneously. Libraries often provide SIMD intrinsics or vectorized operations.
macro
A piece of code in a program that is replaced by a value or block of code before compilation. Macros are typically used for conditional compilation or defining constants.
default template argument
In C++, a fallback value provided for a template parameter if no explicit argument is supplied when the template is instantiated. This can be used to control template behavior.
Filed Under: libstdc++SFINAEDarwintesting