]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Don't advertise cxx_constexpr_string_builtins [PR113658]
authorAlex Coplan <alex.coplan@arm.com>
Wed, 31 Jan 2024 14:50:55 +0000 (14:50 +0000)
committerAlex Coplan <alex.coplan@arm.com>
Tue, 13 Feb 2024 10:53:56 +0000 (10:53 +0000)
commit0d810b7d133c72b7e62b294ffaaf131560ce2391
tree025f5e5691b7895348a42a78b47d71f311aace5e
parentaf6d8d0cc1ac56eba55ef658c664236208f88169
c++: Don't advertise cxx_constexpr_string_builtins [PR113658]

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/has-feature2.C: New test.
gcc/cp/cp-objcp-common.cc
gcc/testsuite/g++.dg/ext/has-feature2.C [new file with mode: 0644]