From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 43E0C3858402; Tue, 8 Aug 2023 16:10:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43E0C3858402 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-x62a.google.com with SMTP id a640c23a62f3a-98377c5d53eso807910966b.0; Tue, 08 Aug 2023 09:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691511014; x=1692115814; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=E63Ecfilf6TLwP1Y+FcwsikxD9QHTJhndOcTr8xFMcA=; b=fSJ9sm2o2GGxWChP0HBRGpvWo7nxyOt2OZeKTMeITmLG0bZuee81T8jWfyx4OBBCIc eRgWjBonF/Ma8qIzE43Pq/IcOVR7sMohoS1uuYVy56QASD0BiFPLK0o0n+mEJPHb1Dc2 U39wMyV2cTG2IsX9l6xb8xNaRvAjuPUzvdAweSvchubEnba/+wrhJ/nMZ/nF8aspfyWa +nM8i1e2ggNzkaPaso3KJ+88oYTaGd7AAmSrjT88ChdyQomlJpcGBekvI9LApPov3xgN 2QRfeDJXOW6t/4tqGpWw/+lJfO9qkisYrPy2W4VLocNtuv8BT1rFs8PUIOj6vCyda4T+ fjnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691511014; x=1692115814; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E63Ecfilf6TLwP1Y+FcwsikxD9QHTJhndOcTr8xFMcA=; b=PM3nHiTFHAU+iezMxlB7uuuMjCK326Qbzp4+ENJsbNBCjLbZajj3PRhlqKga/LWAiJ kwzA7ijMG3H4Sba3fQmJ2FrEqTDtnPzL/NbR9+ckvcK9FQUcMssYcf1nMA/q0xDbRAkY KhCiBtnpT+HfMaCSjylAdP3yL5ydGuinEwN+MW45qVIWE6X6BWGNEiZemyJOAcwuaEdp roVq+NTgGD4+EDOuac59SwADQ1DpJ+gvo0hWCk9polNr3rtUtIUGyaZyYSx9v5cmcdzD HI/7scP2H5sxj1UA7Q0n+wdsS5/bRHjOAweHL6tTB8Od/nJEnGr31UBxCCqYCLKlZ2G3 mjeg== X-Gm-Message-State: AOJu0YzWeoBITx/wv5nm3h19S004rTgC2UNqz8Fa6PPbYVQyRFzaKEPu dKUEmokb/uIkPcjTIcCPnGb0R6pyAaTotgny09A= X-Google-Smtp-Source: AGHT+IELQ/Fu6uM3TKWT+r8lFS/3l1CyVTIrxpi4HYcu7v4dl0fKcLf2c6D60lx5Tok0x46viPo4++hzwIvQCZuoxmA= X-Received: by 2002:a17:906:290:b0:99b:c830:cf23 with SMTP id 16-20020a170906029000b0099bc830cf23mr36835ejf.27.1691511013788; Tue, 08 Aug 2023 09:10:13 -0700 (PDT) MIME-Version: 1.0 References: <3A4C9996-750B-4E3F-8F30-E3DA4366C7B5@berlin.de> <19c14d57-574b-9b31-de5a-a0590e189ce6@berlin.de> <949026CD-7150-4281-9C28-4485C81C62F7@berlin.de> In-Reply-To: From: Jonathan Wakely Date: Tue, 8 Aug 2023 17:10:02 +0100 Message-ID: Subject: Re: GCC support for extensions from later standards To: Nikolas Klauser Cc: Jakub Jelinek , Jason Merrill , gcc@gcc.gnu.org, Louis Dionne , Mark de Wever , aaron@aaronballman.com, "libstdc++" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 Tue, 8 Aug 2023 at 17:07, Jonathan Wakely wrote: > > On Tue, 8 Aug 2023 at 17:04, Nikolas Klauser wrote: > > > > Luckily most of these aren=E2=80=99t problems for libc++. We only suppo= rt the latest GCC. We can only use `if constexpr` in C++11, but that is alr= eady a win I think. > > Can you use it in C++11 though? The body of a constexpr function must > be a single return statement, so if-constexpr isn't allowed. Clang allows it with multiple warnings: ifc.cc:3:6: warning: constexpr if is a C++17 extension [-Wc++17-extensions] if constexpr (sizeof(i) >=3D 4) ^ ifc.cc:3:3: warning: use of this statement in a constexpr function is a C++14 extension [-Wc++14-extensions] if constexpr (sizeof(i) >=3D 4) ^ ifc.cc:8:5: warning: multiple return statements in constexpr function is a C++14 extension [-Wc++14-extensions] return 0; ^ ifc.cc:5:5: note: previous return statement is here return i << 3; ^ But GCC gives a warning for if-constexpr and then an error for the invalid function body: ifc.cc: In function 'constexpr int f(int)': ifc.cc:3:6: warning: 'if constexpr' only available with '-std=3Dc++17' or '-std=3Dgnu++17' [-Wc++17-extensions] 3 | if constexpr (sizeof(i) >=3D 4) | ^~~~~~~~~ ifc.cc:9:1: error: body of 'constexpr' function 'constexpr int f(int)' not a return-statement 9 | } | ^