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.

Reply via email to