Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: FP_CONTRACT was : a MSVC and glibc-compatible fmod() Date: Sat, 01 Mar 2025 08:35:01 -0800 Organization: A noiseless patient Spider Lines: 49 Message-ID: <86ikosyaiy.fsf@linuxsc.com> References: <20250224171343.000016aa@yahoo.com> <20250224175258.00002799@yahoo.com> <20250225172618.00005646@yahoo.com> <20250225191715.00001a55@yahoo.com> <20250226003549.0000251b@yahoo.com> <20250226142721.0000375b@yahoo.com> <20250228162832.000033d0@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Sat, 01 Mar 2025 17:35:02 +0100 (CET) Injection-Info: dont-email.me; posting-host="9203c2f2c7587d3e1ef2ab3ddd3e77d6"; logging-data="316124"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18N+AFwgc+LjRk8hGTC8rKHXwNgWH52VNA=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:aGryb2fwCZbQJLCaLkKQRfDrDJI= sha1:1QFJwxMmq28vEf7+st0S0y5nI/w= Xref: csiph.com comp.lang.c++:121738 Michael S writes: > On Wed, 26 Feb 2025 14:39:34 -0000 (UTC) > Muttley@DastardlyHQ.org wrote: > >> On Wed, 26 Feb 2025 14:27:21 +0200 >> Michael S wibbled: >> >>> On Wed, 26 Feb 2025 08:16:01 -0000 (UTC) >>> Muttley@DastardlyHQ.org wrote: >>> I played a little on godbolt and it seems that the bug is relatively >>> new. clang 13 still generates correct code. clang 14 does not. I.e. >>> slightly less than 3 years. >> >> I don't think they've noticed: >> >> R8603$ cc --version >> Apple clang version 16.0.0 (clang-1600.0.26.6) > > More googling/stack-overflowing. > > clang/LLVM people think that it is a feature rather than a bug. They > claim that the standard allows fusing. I think that they are wrong, but > I didn't read the respective part of the standard. My reading of the C standard is that implementations are allowed to contract floating-point expressions (aka fusing) as their default choice of what is allowed, and because this default choice falls into the category of implementation-defined behavior the implementation must document what default it has chosen. > The behavior can be turned back into clang13 way by -ffp-contract=off. > Or with pragma > #pragma STDC FP_CONTRACT OFF The C standard doesn't say anything about compiler options. The C standard does specify what happens for the STDC FP_CONTRACT standard #pragma, for both #pragma STDC FP_CONTRACT OFF and #pragma STDC FP_CONTRACT ON If you want to look, what these #pragma's do is defined in the section of the C standard pertaining to , which is 7.12 in the N1256 document for C99.