https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126807
Bug ID: 126807
Summary: simd: Tests fail on Darwin since their introduction.
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: rejects-valid, testsuite-fail
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: iains at gcc dot gnu.org
CC: mkretz at gcc dot gnu.org
Target Milestone: ---
Target: *-*-darwin*
14 simd tests introduced in r16-8243-g8be0893fd98c9a have always failed on
darwin. Since the change to add c++29 that now gives 28 fails in libstdc++.
See, for example:
https://gcc.gnu.org/pipermail/gcc-testresults/2026-August/884410.html
The reason is that Darwin defines math_errhandling as a function rather than a
constant. It seems that the intent was for that case to be a substitution
failure so the __handle_fpexcept_impl fallback is chosen instead. However,
requires-clause used to do this mentions no template parameter, so it is
non-dependent and is checked at the point of definition: there is no
substitution, so there is no substitution failure and no fallback, and a
non-constant math_errhandling is a hard error.
A possible solution would be to make the math_errhandling a template param,
thus triggering SFINAE, like below - or open to other solutions (this is not
the end of the story - fixing this exposes two other issues - one of which is a
long-term compiler-side bug). Will cross-reference those when filed.
---- possible substitution fix....
diff --git a/libstdc++-v3/include/bits/simd_details.h
b/libstdc++-v3/include/bits/simd_details.h
index a3ec38f0dc0..46eab585eb9 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.