This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Finish implementing P0426R1 "Constexpr for std::char_traits" for C++17


On 23/04/17 19:33 +0100, Pedro Alves wrote:
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.)

Pedro, this is OK for trunk now we're in stage 1. Please go ahead and
commit it - thanks.

It's probably safe for gcc-7-branch too, but let's leave it on trunk
for a while first.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]