[committed] libstdc++: Only use __builtin_sprintf if supported [PR 96083]

Jonathan Wakely jwakely@redhat.com
Wed Dec 16 19:28:43 GMT 2020


On 16/12/20 17:02 +0000, Jonathan Wakely wrote:
>On 16/12/20 09:23 -0700, Martin Sebor via Libstdc++ wrote:
>>On 12/16/20 8:00 AM, Jonathan Wakely via Gcc-patches wrote:
>>>Clang doesn't support __builtin_sprintf, so use std::sprintf instead.
>>>
>>>libstdc++-v3/ChangeLog:
>>>
>>>	PR libstdc++/96083
>>>	* include/ext/throw_allocator.h: Use __has_builtin to check for
>>>	__builtin_sprintf support, and use std::sprtinf if necessary.
>>>
>>>Tested powerpc64le-linux. Committed to trunk.
>>>
>>
>>I expected to see the test itself guarded by #ifdef __has_builtin
>>like in <utility>.  Or is this code only [meant to be] used with
>>compilers that understand __has_builtin?  (I'm mostly just curious
>>here about support for other compilers like ICC, not necessarily
>>pointing out a problem with the patch.)
>
>All recent versions of Intel and Clang support __has_builtin.
>(For Intel __has_builtin(__builtin_sprintf) is true, for Clang it's
>false. But they both support checking it.)
>
>The #ifdef __has_builtin in <utility> was added more than three years
>ago, before GCC supported __has_builtin. So that check was there to
>make the code work with GCC, not other compilers.
>
>Now that GCC supports it, I can simplify that.

Like so.

Tested powerpc64-linux, committed to trunk.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 2143 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201216/501cb74a/attachment-0001.bin>


More information about the Libstdc++ mailing list