[libcxx] r260337 - Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from

Ismail Donmez via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 11:02:31 PST 2016


Hi,

On Wed, Feb 10, 2016 at 2:59 AM, Richard Smith via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: rsmith
> Date: Tue Feb  9 18:59:02 2016
> New Revision: 260337
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260337&view=rev
> Log:
> Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from
> <string.h> and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from <wchar.h> to
> provide a const-correct overload set even when the underlying C library does
> not.
>
> This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined)
> specifies that a given overload is a better match than an otherwise equally
> good function declaration without the overload. This is implemented in modern
> versions of Clang via __attribute__((enable_if)), and not elsewhere.
>
> We use this new macro to define overloads in the global namespace for these
> functions that displace the overloads provided by the C library, unless we
> believe the C library is already providing the correct signatures.
>
> Added:
>     libcxx/trunk/include/string.h
>       - copied, changed from r251642, libcxx/trunk/include/string.h
> Modified:
>     libcxx/trunk/include/__config
>     libcxx/trunk/include/cstring
>     libcxx/trunk/include/cwchar
>     libcxx/trunk/include/wchar.h
>     libcxx/trunk/test/std/depr/depr.c.headers/string_h.pass.cpp
>     libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp
>     libcxx/trunk/test/std/strings/c.strings/cstring.pass.cpp
>     libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp

Fails on Linux x86-64 with glibc 2.22:

/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/depr/depr.c.headers/string_h.pass.cpp:55:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(strchr(cpc, 0)), const
char*>::value), "");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/depr/depr.c.headers/string_h.pass.cpp:56:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(strpbrk(cpc, cpc)), const
char*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/depr/depr.c.headers/string_h.pass.cpp:57:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(strrchr(cpc, 0)), const
char*>::value), "");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/depr/depr.c.headers/string_h.pass.cpp:58:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(strstr(cpc, cpc)), const
char*>::value), "");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/depr/depr.c.headers/string_h.pass.cpp:59:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(memchr(vpc, 0, s)), const
void*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.


/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/strings/c.strings/cstring.pass.cpp:55:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)),
const void*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/strings/c.strings/cstring.pass.cpp:56:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const
char*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/strings/c.strings/cstring.pass.cpp:57:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)),
const char*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/strings/c.strings/cstring.pass.cpp:58:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const
char*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/llvm/projects/libcxx/test/std/strings/c.strings/cstring.pass.cpp:59:5:
error: static_assert failed ""
    static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const
char*>::value), "");
    ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.


More information about the cfe-commits mailing list