https://gcc.gnu.org/g:4ccaab59f55c622c8befa284fb3c291669c445d8

commit r17-4134-g4ccaab59f55c622c8befa284fb3c291669c445d8
Author: Iain Sandoe <[email protected]>
Date:   Sat Aug 8 20:33:13 2026 +0100

    libstdc++: Arrange for non-constant math_errhandling to SFINAE [PR126807]
    
    14 simd testcases fail to build on Darwin because math_errhandling is a 
macro
    that resolves to a function, rather than a constant.  At present the macro
    is present in a non-dependent requires clause and so is not substituted.  We
    need this to SFINAE in the immediate context.
    
    Solution proposed here is to use the macro as a default template argument
    instead.
    
            PR libstdc++/126807
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/simd_details.h: Make the math_errhandling
            macro into a default template argument.
    
    Signed-off-by: Iain Sandoe <[email protected]>

Diff:
---
 libstdc++-v3/include/bits/simd_details.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/simd_details.h 
b/libstdc++-v3/include/bits/simd_details.h
index a3ec38f0dc02..46eab585eb95 100644
--- a/libstdc++-v3/include/bits/simd_details.h
+++ b/libstdc++-v3/include/bits/simd_details.h
@@ -422,12 +422,14 @@ namespace simd
   // math_errhandling may expand to an extern symbol, in which case we must 
assume fp exceptions
   // need to be considered. A conforming C library must define 
math_errhandling, but in case it
   // isn't defined we simply use the fallback.
+  // The macro is used as default template argument (rather than in a 
requires-clause) so that a
+  // non-constant math_errhandling is a substitution failure in the immediate 
context instead of a
+  // hard error at the point of definition.
 #ifdef math_errhandling
-  template <int = 0>
-    requires requires { typename bool_constant<0 != (math_errhandling & 
MATH_ERREXCEPT)>; }
+  template <int _ErrHandling = math_errhandling>
     consteval bool
     __handle_fpexcept_impl(int)
-    { return 0 != (math_errhandling & MATH_ERREXCEPT); }
+    { return 0 != (_ErrHandling & MATH_ERREXCEPT); }
 #endif
 
   // Fallback if math_errhandling doesn't work: implement correct exception 
behavior.

Reply via email to