On 04/23/2017 06:54 PM, Pedro Alves wrote:
Hi!
As I had suggested in PR c++/80265, here's a patch that uses
__builtin_constant_p to tell whether we can defer to a constexpr
algorithm, which avoids having to wait for compiler support.
Unfortunately I ran out of cycles today to run a full bootstrap/regtest
cycle, but constexpr_functions_c++17.cc passes cleanly on
x86_64 GNU/Linux at least.
If this looks like a reasonable approach, I can maybe try running
full tests on the gcc compile farm next week.
WDYT?
Reading the patch via the list made me spot something
that was incorrect.
- static char_type*
+ static _GLIBCXX17_CONSTEXPR char_type*
assign(char_type* __s, size_t __n, char_type __a)
{
+#if __cplusplus > 201402
+ if (__constant_string_p(__s)
This should probably have been __constant_char_array_p, but now
that I look again at the paper, I see I got myself confused -- this
assign overload is not meant to be constexpr in the first place.
So here's an updated patch that drops that bit. (Same testing
as before.)