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

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 11:44:48 PST 2016


Should be fixed in r260570.

On Thu, Feb 11, 2016 at 11:28 AM, Richard Smith <richard at metafoo.co.uk> wrote:
> Argh, the glibc folks broke their string.h and wchar.h prototypes in
> this commit:
>
> https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8e2e833ac4d6509b152d6b8d74d388725717c56f
>
> On Thu, Feb 11, 2016 at 11:02 AM, Ismail Donmez <ismail at i10z.com> wrote:
>> 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