Use __builtin___stpncpy_chk when available
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 12 Nov 2020 06:39:56 +0000 (12:09 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 12 Nov 2020 09:06:43 +0000 (14:36 +0530)
commit7163ace3318d666d40771f5c8e7c4a148827070f
treee4069e211ca40c78133ae26d3c1eb57919ef345b
parentee9946ce3c176092fb5fbabc7406a39479565a1b
Use __builtin___stpncpy_chk when available

The builtin has been available in gcc since 4.7.0 and in clang since
2.6.  This fixes stpncpy fortification with clang since it does a
better job of plugging in __stpncpy_chk in the right place than the
header hackery.

This has been tested by building and running all tests with gcc 10.2.1
and also with clang tip as of a few days ago (just the tests in debug/
since running all tests don't work with clang at the moment) to make
sure that both compilers pass the stpncpy tests.
string/bits/string_fortified.h