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

Jonathan Wakely jwakely@redhat.com
Wed Dec 16 17:04:44 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.)

I recently discussed this subject with Judy Ward at Intel, and their
preference is for libstdc++ to use __has_builtin, see
6aa12274007bccbae2691a9d336c37fe167bb535 for a recent change to fix
feature detection for Intel.



More information about the Libstdc++ mailing list