]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: const void* memchr [PR113706]
authorJason Merrill <jason@redhat.com>
Mon, 12 Feb 2024 23:24:00 +0000 (18:24 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 1 May 2024 15:44:13 +0000 (11:44 -0400)
commitc3bc2787b8beb7aae67fdf2a7f7271a9a4edca7c
treecf9589f3453380733238ab09459e55d19f0eeb33
parent0695aba3e987f4bb06c95f29ff90a8a3234e1507
c++: const void* memchr [PR113706]

The C++ standard specifies that the <string.h> functions have const and
non-const overloads, unlike C's single function with const argument and
non-const return.  Many systems don't actually implement this, but only add
an overload with non-const argument, so both end up having non-const return.
Solaris <string.h> does what the standard says, but we were penalizing it by
not recognizing the const overload as the built-in memchr.

PR c++/113706

gcc/cp/ChangeLog:

* decl.cc (decls_match): Handle memchr return type being
const-qualified.

gcc/testsuite/ChangeLog:

* g++.dg/opt/const-builtin1.C: New test.
* c-c++-common/pr103798-2.c: Remove xfail.
gcc/cp/decl.cc
gcc/testsuite/c-c++-common/pr103798-2.c
gcc/testsuite/g++.dg/opt/const-builtin1.C [new file with mode: 0644]