https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113658
Bug ID: 113658
Summary: GCC 14 has incomplete impl for declared feature
"cxx_constexpr_string_builtins"
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: berrange at redhat dot com
Target Milestone: ---
In GCC 14 there was support for the Clang __has_feature() language extension
added by
commit 06280a906cb3dc80cf5e07cf3335b758848d488d
Author: Alex Coplan <[email protected]>
Date: Fri Mar 17 16:30:51 2023 +0000
c-family: Implement __has_feature and __has_extension [PR60512]
This patch implements clang's __has_feature and __has_extension in GCC.
Currently the patch aims to implement all documented features (and some
undocumented ones) following the documentation at
https://clang.llvm.org/docs/LanguageExtensions.html with the exception
of the legacy features for C++ type traits.
One of the features declared as implemented is "cxx_constexpr_string_builtins"
which was documented by CLang as indicating support for built-ins for memchr,
memcmp, strchr, strcmp, strlen, strncmp, wcschr, wcscmp, wcslen, wcsncmp,
wmemchr, wmemcmp, and one extra special case for memchr.
Except GCC 14 does not provide built-ins for all those functions, so GCC is
claiming support for a feature it cannot fully support.
As a result code that was written against this CLang feature extension now gets
enabled with GCC 14 and then fails to build.
$ cat >> demo.cpp <<EOF
#include <string.h>
#ifndef __has_feature
#warning "no __has_feature"
#define __has_feature(a) 0
#endif
char *foo(const char *s, int c, size_t n) {
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_char_memchr(s, c, n);
#else
#warning "no __builtin_char_memchr"
return NULL;
#endif
}
EOF
$ g++ b.cpp
b.cpp: In function ‘char* foo(const char*, int, size_t)’:
b.cpp:10:12: error: ‘__builtin_char_memchr’ was not declared in this scope; did
you mean ‘__builtin_memchr’?
10 | return __builtin_char_memchr(s, c, n);
| ^~~~~~~~~~~~~~~~~~~~~
| __builtin_memchr
gcc version 14.0.1 20240125 (Red Hat 14.0.1-0) (GCC)