[PATCH] libstdc++: Flag Annex G bit from GCC __GCC_IEC_559_COMPLEX.

Jonathan Wakely jwakely@redhat.com
Fri Oct 23 13:42:17 GMT 2026


On Sun, 27 Sept 2026 at 15:09, Iain Sandoe <iains.gcc@gmail.com> wrote:
>
> std/simd/arithmetic.cc fails everywhere on Darwin because libc there does
> not define __STDC_IEC_60559_COMPLEX__.  Fixed by using the compiler's
> indicator if libc does not emit one.  Tested on x86_64 linux/darwin,
> OK for trunk? thanks
> Iain
>
> --- 8< ---
>
> __STDC_IEC_60559_COMPLEX__ is not a compiler pre-define; it is provided
> by glibc but not necessarily by other libc implementations.
>
> However the compiler does support Annex G and emits __GCC_IEC_559_COMPLEX
> to indicate this (where the value is > 0).  Use the compiler's value where
> __STDC_IEC_60559_COMPLEX__ is absent.
>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/simd_details.h: Use __GCC_IEC_559_COMPLEX to
>         determine IEC60559 complex support.
>
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
>  libstdc++-v3/include/bits/simd_details.h | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/simd_details.h b/libstdc++-v3/include/bits/simd_details.h
> index 46eab585eb9..29a7195c539 100644
> --- a/libstdc++-v3/include/bits/simd_details.h
> +++ b/libstdc++-v3/include/bits/simd_details.h
> @@ -532,8 +532,13 @@ namespace simd
>
>         // C Annex G defines the behavior of complex<T> where T is IEC60559 floating-point. If
>         // __STDC_IEC_60559_COMPLEX__ is defined then Annex G is implemented - and simd<complex>
> -       // will do so as well. However, Clang never defines the macro.
> -#if defined __STDC_IEC_60559_COMPLEX__ || defined __STDC_IEC_559_COMPLEX__ || defined _GLIBCXX_CLANG
> +       // will do so as well. However, __STDC_IEC_60559_COMPLEX__ is defined (if at all)
> +       // by the C library and will typically be absent on non-glibc targets.
> +       // GCC nevertheless implements Annex G and std::complex relies on it; the compiler
> +       // emits __GCC_IEC_559_COMPLEX with value > 0 where it is enabled/valid.
> +       // Clang is flagged to support it unconditionally.
> +#if defined __STDC_IEC_60559_COMPLEX__ || defined __STDC_IEC_559_COMPLEX__ \
> +      || (defined __GCC_IEC_559_COMPLEX && __GCC_IEC_559_COMPLEX > 0) || defined _GLIBCXX_CLANG

We don't generally care about -Wundef warnings because libstdc++ is
riddled with them, so the __GCC_IEC_559_COMPLEX > 0 part is enough,
without first testing if it's defined.

But it doesn't do any harm.

OK for trunk


>           + (1 << 10)
>  #endif
>  #if __SUPPORT_SNAN__
> --
> 2.50.1 (Apple Git-155)
>



More information about the Libstdc++ mailing list