public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113658] New: GCC 14 has incomplete impl for declared feature "cxx_constexpr_string_builtins"
@ 2024-01-29 16:47 berrange at redhat dot com
  2024-01-29 16:51 ` [Bug c++/113658] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: berrange at redhat dot com @ 2024-01-29 16:47 UTC (permalink / raw)
  To: gcc-bugs

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 <alex.coplan@arm.com>
  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)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-02-13 10:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29 16:47 [Bug c++/113658] New: GCC 14 has incomplete impl for declared feature "cxx_constexpr_string_builtins" berrange at redhat dot com
2024-01-29 16:51 ` [Bug c++/113658] " pinskia at gcc dot gnu.org
2024-01-29 16:54 ` pinskia at gcc dot gnu.org
2024-01-29 20:59 ` jakub at gcc dot gnu.org
2024-01-29 21:37 ` berrange at redhat dot com
2024-01-30  8:58 ` acoplan at gcc dot gnu.org
2024-01-30  9:02 ` jakub at gcc dot gnu.org
2024-02-13 10:55 ` cvs-commit at gcc dot gnu.org
2024-02-13 10:56 ` acoplan at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).