From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 40F663858439 for ; Thu, 15 Sep 2022 06:40:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40F663858439 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x630.google.com with SMTP id gh9so39838417ejc.8 for ; Wed, 14 Sep 2022 23:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=tC1YAR4xUYSnY/q0oSBn9jd0cSsVHJOTZklbdDTOGQ8=; b=QURiNbjkFpfrvbtcGwJSUgqodxn6MHBli/pLlY7tI3BCm7rWhzY8xB9yJMbWNzZf2x GxC4kYSZlEO8ProjBujw4lxNBlEjjmj3JbuLCUEvp0jtqo+QLyRW5iM6HoDamLKb4ZYZ bagFsCC+30q1Ut2A+tA9r3DDmcQf2Z/CmMSRd/dAOVrzHomw+gVM1no9xe3GnmGvcNCq W1/NVwtl/8/F1U0Ah++AWjtLhRRSSoppcdYAlUiZzZXDjZ9qBVbdZY0/huzxRMAbIz1l QyjKnELd8N97G3h+xLYzWuCxy7Bk6CQ2uo2gjZhtcQVHQR6hf2rlhmCyOIOq9oYyp1H5 RABw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=tC1YAR4xUYSnY/q0oSBn9jd0cSsVHJOTZklbdDTOGQ8=; b=6Dvp6vzkv2eOGSdavhz+hAA5GL8odqQCWnMdH3+lpt6ES0ElOxETADDAd2Z4MfidYz MPgwTCcekyvxckNYXeiUhvrgEPg77G0gImYJyGeSXhiLFrwHS672HvQmZ9vvnH0948eU oVUrkbRawBqVMuBK/kzvXdRZgM1umzot7vG2aPgtMUqQWr1+5Ys/pgtoXVr6WCVOIH+z UThEDjjlBWhck58vvvoHZ86gF0vhqHtL046Bx9YunYtGRn6gROxhOh77qhN7x4Hx17CT RPzFSBUgzaVj+guetQHnuA2iOF87LjK3jA4xcR8F01E9zOvygfnYpntwmAS4gI4uh4Dx 4hxw== X-Gm-Message-State: ACgBeo0sUd3+Iw40+HFyBger/hEc9DvGuXboyhAl1e/5pOUdKe+/Ra/d +umYujvAlfjgcYJ150DZuVEa+eb0PeG7SKfHLdc= X-Google-Smtp-Source: AA6agR7kxx6RYtzOGVPTJfWM7GgMFoYLTh1eKDud0CFTsa3wVc/YdtoEtNgxEpceKytB88Ikgvsk9uTZz0NzIAV3YD0= X-Received: by 2002:a17:907:7632:b0:76f:f6e7:36cf with SMTP id jy18-20020a170907763200b0076ff6e736cfmr29438588ejc.442.1663224044867; Wed, 14 Sep 2022 23:40:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Thu, 15 Sep 2022 08:40:32 +0200 Message-ID: Subject: Re: float.h: Do not define INFINITY for C2x when infinities not supported To: Joseph Myers Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Sep 15, 2022 at 1:02 AM Joseph Myers wrote: > > C2x has changed the rules for defining INFINITY in so it is > no longer defined when float does not support infinities, instead of > being defined to an expression that overflows at translation time. > Thus, make the definition conditional on __FLT_HAS_INFINITY__ (this is > already inside a C2x-conditional part of , because previous C > standard versions only had this macro in ). > > Bootstrapped with no regressions for x86_64-pc-linux-gnu. Also did a > spot test of the case of no infinities supported by building cc1 for > vax-netbsdelf and testing compiling the new c2x-float-11.c test with > it. Ok > gcc/ > * ginclude/float.h (INFINITY): Define only if > [__FLT_HAS_INFINITY__]. > > gcc/testsuite/ > * gcc.dg/c2x-float-2.c: Require inff effective-target. > * gcc.dg/c2x-float-11.c: New test. > > diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h > index 9d368c4afa5..afe4a712878 100644 > --- a/gcc/ginclude/float.h > +++ b/gcc/ginclude/float.h > @@ -257,9 +257,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > #define DBL_IS_IEC_60559 __DBL_IS_IEC_60559__ > #define LDBL_IS_IEC_60559 __LDBL_IS_IEC_60559__ > > -/* Infinity in type float, or overflow if infinity not supported. */ > +/* Infinity in type float; not defined if infinity not supported. */ > +#if __FLT_HAS_INFINITY__ > #undef INFINITY > #define INFINITY (__builtin_inff ()) > +#endif > > /* Quiet NaN, if supported for float. */ > #if __FLT_HAS_QUIET_NAN__ > diff --git a/gcc/testsuite/gcc.dg/c2x-float-11.c b/gcc/testsuite/gcc.dg/c2x-float-11.c > new file mode 100644 > index 00000000000..0e2f3c0c97a > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/c2x-float-11.c > @@ -0,0 +1,9 @@ > +/* Test INFINITY macro. Test when infinities not supported. */ > +/* { dg-do compile { target { ! inff } } } */ > +/* { dg-options "-std=c2x" } */ > + > +#include > + > +#ifdef INFINITY > +#error "INFINITY defined" > +#endif > diff --git a/gcc/testsuite/gcc.dg/c2x-float-2.c b/gcc/testsuite/gcc.dg/c2x-float-2.c > index 4f669fd39bc..61a77f6f2db 100644 > --- a/gcc/testsuite/gcc.dg/c2x-float-2.c > +++ b/gcc/testsuite/gcc.dg/c2x-float-2.c > @@ -1,8 +1,8 @@ > -/* Test INFINITY macro. Generic test even if infinities not > - supported. */ > +/* Test INFINITY macro. Generic test. */ > /* { dg-do run } */ > /* { dg-options "-std=c2x -w" } */ > /* { dg-add-options ieee } */ > +/* { dg-require-effective-target inff } */ > > #include > > > -- > Joseph S. Myers > joseph@codesourcery.com