From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6EC353858403 for ; Fri, 2 Feb 2024 16:27:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EC353858403 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6EC353858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706891239; cv=none; b=bkshzTX84RhSZnT1qsYeryCuw5xoi7o+6I4EQdZEZXZP4uYhpZ/WPqIjInQJP23zjUNgRK4iPV+l2BKggMjj284IgI63venZeYH2lf6hlI8xGiVKffaf1tSJh6nHLeM0voNYzNKFb3CKJBFNfJCSQIDG6q9grIgSSS8prQ7J5wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706891239; c=relaxed/simple; bh=jCj8tYKhc8AN/bAPSpgr2JSgCARhHfIGVMOxWUDRm9k=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=B6PWtY/JFY+XIsnyPBoVua6CMr/gl6hyrj3ZL24BqXlnikt/pg4H5wabGmC7wKFDBO85iI555Q0F9W6kXybpT1oQQVVlw8dBLX4Sm8v5hwkEZGBX88dxRHBW6Xrb6IIY2CpK2hSHYjZPJcySFFzLsYKnXrlpBi+cNyp2QZUTQIw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706891234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1Y3yU8VDtepVdAAjW2hUIomXR+xZMQi6wkAkkTmzsdQ=; b=fAIZ07QMbwp1dnhhsKC73icxYYFAx8UHfUyejuV9sDZJ3AhL1ihdfHdgKJew54dxreROLf qMLMNwMUH4aryOD6wF/0FEQJvByzKk9kLjfFQua19RS8dmOpANX0xSOaa/vpryavu7yeP2 Nf8/sjn/bEsdlNiSmxol8zRoGnvZIpU= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-QlJCDI8yNBGHGtxFRb-5HQ-1; Fri, 02 Feb 2024 11:27:12 -0500 X-MC-Unique: QlJCDI8yNBGHGtxFRb-5HQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7855f31ecb2so32587585a.1 for ; Fri, 02 Feb 2024 08:27:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706891232; x=1707496032; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Y3yU8VDtepVdAAjW2hUIomXR+xZMQi6wkAkkTmzsdQ=; b=gEBbZUl8V2lK3OfFjxiwhPjxNqOxuaM3z33WTcA9/azXa2lsEkc+aHT3TYVs/hVPoa aQxM8WL/kCfIGbKdDEQEhFEs9os+Ol8onJTfRyKC9qFIKfE1sQezUBcLm79pD3DdcuGr tkmeO6RnSWJW+hoKbMJyE22d+UHchmgPjzW1JT27ZHjC12GCO80ovUsUWoqOylXsSFMF l//EfyG6DCBErhMWv9dM0YDJePBvLDLVD4xlTzFjcvfUhmkk0pvL9LwcRGWf8Y0XD5oy 3TB8luUQxA8/el1J7oi04uuZRgM/Hn1x+oQsQvkwHEEs8QblYFmqUe+/DMbjfeaeNAXt qrPg== X-Gm-Message-State: AOJu0Yxa5XcrgU3dk9YKONlIEOkh9K1LNf9X561ck8llVOt26xcHlC+m H2IpqzFstZMjOChxCO0psJm83oD7+sPVx1rfxnMRv+qXGumTetIrMIIY2AEP7kAQ7MCUAB8dizC lQ4mKUkHkPmLsIiSCWuhTbyc5AnC7jufhGC7HBGsl39r/AweGnRAa4Ds= X-Received: by 2002:a05:620a:44ca:b0:784:796:e4a1 with SMTP id y10-20020a05620a44ca00b007840796e4a1mr5019310qkp.36.1706891232410; Fri, 02 Feb 2024 08:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhIt/CxWNGmwzgIEOpFxDkX675heD0p9L9fwHFNI5YS2EFr3SSkh++DqUgdACxF5+VUsAnWg== X-Received: by 2002:a05:620a:44ca:b0:784:796:e4a1 with SMTP id y10-20020a05620a44ca00b007840796e4a1mr5019286qkp.36.1706891232137; Fri, 02 Feb 2024 08:27:12 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX6HXP9n/Utc3KopDptBTyJDYsl6qrXfPKvgx1D/k9pwpd0Aaavy0MKO9w2DwvqvuA5khQuNMtSJ9Tk/YY2fE9gigK2nOWYdL9V6wNEaQk9JQ== Received: from redhat.com (2603-7000-9500-34a5-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:34a5::1db4]) by smtp.gmail.com with ESMTPSA id m6-20020ae9e006000000b00783dc97436dsm800289qkk.13.2024.02.02.08.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:27:11 -0800 (PST) Date: Fri, 2 Feb 2024 11:27:09 -0500 From: Marek Polacek To: Alex Coplan Cc: gcc-patches@gcc.gnu.org, Jason Merrill , Nathan Sidwell Subject: Re: [PATCH] c++: Don't advertise cxx_constexpr_string_builtins [PR113658] Message-ID: References: MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,LIKELY_SPAM_BODY,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Fri, Feb 02, 2024 at 03:45:48PM +0000, Alex Coplan wrote: > On 02/02/2024 09:34, Marek Polacek wrote: > > On Fri, Feb 02, 2024 at 10:27:23AM +0000, Alex Coplan wrote: > > > Bootstrapped/regtested on x86_64-apple-darwin, OK for trunk? > > > > > > Thanks, > > > Alex > > > > > > -- >8 -- > > > > > > When __has_feature was introduced for GCC 14, I included the feature > > > cxx_constexpr_string_builtins, since of the relevant string builtins > > > that GCC implements, it seems to support constexpr evaluation of those > > > builtins. > > > > > > However, as the PR shows, GCC doesn't implement the full list of > > > builtins in the clang documentation. After enumerating the builtins, > > > the clang docs [1] say: > > > > > > > Support for constant expression evaluation for the above builtins can > > > > be detected with __has_feature(cxx_constexpr_string_builtins). > > > > > > and a strict reading of this would suggest we can't really support > > > constexpr evaluation of a builtin if we don't implement the builtin in > > > the first place. > > > > > > So the conservatively correct thing to do seems to be to stop > > > advertising the feature altogether to avoid failing to build code which > > > assumes the presence of this feature implies the presence of all the > > > builtins listed in the clang documentation. > > > > > > [1] : https://clang.llvm.org/docs/LanguageExtensions.html#string-builtins > > > > > > gcc/cp/ChangeLog: > > > > > > PR c++/113658 > > > * cp-objcp-common.cc (cp_feature_table): Remove entry for > > > cxx_constexpr_string_builtins. > > > > > > gcc/testsuite/ChangeLog: > > > > > > PR c++/113658 > > > * g++.dg/ext/pr113658.C: New test. > > > > > diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc > > > index f06edf04ef0..85dde0459fa 100644 > > > --- a/gcc/cp/cp-objcp-common.cc > > > +++ b/gcc/cp/cp-objcp-common.cc > > > @@ -110,7 +110,6 @@ static constexpr cp_feature_info cp_feature_table[] = > > > { "cxx_alignof", cxx11 }, > > > { "cxx_attributes", cxx11 }, > > > { "cxx_constexpr", cxx11 }, > > > - { "cxx_constexpr_string_builtins", cxx11 }, > > > { "cxx_decltype", cxx11 }, > > > { "cxx_decltype_incomplete_return_types", cxx11 }, > > > { "cxx_default_function_template_args", cxx11 }, > > > diff --git a/gcc/testsuite/g++.dg/ext/pr113658.C b/gcc/testsuite/g++.dg/ext/pr113658.C > > > new file mode 100644 > > > index 00000000000..f4a34888f28 > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/ext/pr113658.C > > > > Might be better to name this has-feature2.C > > > > > @@ -0,0 +1,13 @@ > > > > Please include > > // PR c++/113658 > > Can do. > > > > > > +// { dg-do compile } > > > +// { dg-options "" } > > > > Why dg-options ""? It doesn't seem to have any purpose here. > > That is to disable -pedantic-errors which IIRC is added by default in > the testsuite options. Right. > With -pedantic-errors we would have __has_extension behaving like > __has_feature, and I wanted to check in the test that this doesn't get > reported as a feature or extension. Oh I see. A comment to that effect might be helpful. Otherwise LGTM, thanks. Marek