https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80265

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #21 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to palves from comment #19)
> Author: palves
> Date: Mon Jun 12 22:22:39 2017
> New Revision: 249137
> 
> URL: https://gcc.gnu.org/viewcvs?rev=249137&root=gcc&view=rev
> Log:
> Finish implementing P0426R1 "Constexpr for std::char_traits" for C++17
> 
> As discussed in PR c++/80265 ("__builtin_{memcmp,memchr,strlen} are
> not usable in constexpr functions"), use __builtin_constant_p to tell
> whether we can defer to a constexpr algorithm.
> 
> I used __always_inline__ just to be thorough.  It isn't really really
> necessary as far as I could determine.
> 
> Changes like these:
> 
>        if (__n == 0)
>          return 0;
>  -    return wmemcmp(__s1, __s2, __n);
>  +    else
>  +      return wmemcmp(__s1, __s2, __n);
> 
> are necessary otherwise G++ complains that we're calling a
> non-constexpr function, which looks like a a manifestation of PR67026
> to me.
> 
> libstdc++-v3:
> 2017-06-12  Pedro Alves  <pal...@redhat.com>
> 
>       * doc/xml/manual/status_cxx2017.xml: Update C++17 constexpr
>       char_traits status.
>       * doc/html/*: Regenerate.
> 
>       * include/bits/char_traits.h (_GLIBCXX_ALWAYS_INLINE): Define if
>       not already defined.
>       (__cpp_lib_constexpr_char_traits): Uncomment.
>       (__constant_string_p, __constant_char_array_p): New.
>       (std::char_traits<char>, std::char_traits<wchar_t>): Add
>       _GLIBCXX17_CONSTEXPR on compare, length and find and use
>       __constant_string_p, __constant_char_array_p and
>       __builtin_constant_p to defer to __gnu_cxx::char_traits at compile
>       time.
> 
>       * testsuite/21_strings/char_traits/requirements/
>       constexpr_functions_c++17.cc: Uncomment
>       __cpp_lib_constexpr_char_traits tests.  Uncomment
>       test_compare<char>, test_length<char>, test_find<char>,
>       test_compare<wchar_t>, test_length<wchar_t> and test_find<wchar_t>
>       static_assert tests.
> 
> Modified:
>     trunk/libstdc++-v3/ChangeLog
>     trunk/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
>     trunk/libstdc++-v3/include/bits/char_traits.h
>    
> trunk/libstdc++-v3/testsuite/21_strings/char_traits/requirements/
> constexpr_functions_c++17.cc

(In reply to Jonathan Wakely from comment #20)
> Author: redi
> Date: Tue Sep 12 16:27:01 2017
> New Revision: 252030
> 
> URL: https://gcc.gnu.org/viewcvs?rev=252030&root=gcc&view=rev
> Log:
> Finish implementing P0426R1 "Constexpr for std::char_traits" for C++17
> 
> As discussed in PR c++/80265 ("__builtin_{memcmp,memchr,strlen} are
> not usable in constexpr functions"), use __builtin_constant_p to tell
> whether we can defer to a constexpr algorithm.
> 
> I used __always_inline__ just to be thorough.  It isn't really really
> necessary as far as I could determine.
> 
> Changes like these:
> 
>        if (__n == 0)
>          return 0;
>  -    return wmemcmp(__s1, __s2, __n);
>  +    else
>  +      return wmemcmp(__s1, __s2, __n);
> 
> are necessary otherwise G++ complains that we're calling a
> non-constexpr function, which looks like a a manifestation of PR67026
> to me.
> 
> libstdc++-v3:
> 2017-06-12  Pedro Alves  <pal...@redhat.com>
> 
>       * doc/xml/manual/status_cxx2017.xml: Update C++17 constexpr
>       char_traits status.
>       * doc/html/*: Regenerate.
> 
>       * include/bits/char_traits.h (_GLIBCXX_ALWAYS_INLINE): Define if
>       not already defined.
>       (__cpp_lib_constexpr_char_traits): Uncomment.
>       (__constant_string_p, __constant_char_array_p): New.
>       (std::char_traits<char>, std::char_traits<wchar_t>): Add
>       _GLIBCXX17_CONSTEXPR on compare, length and find and use
>       __constant_string_p, __constant_char_array_p and
>       __builtin_constant_p to defer to __gnu_cxx::char_traits at compile
>       time.
> 
>       * testsuite/21_strings/char_traits/requirements/
>       constexpr_functions_c++17.cc: Uncomment
>       __cpp_lib_constexpr_char_traits tests.  Uncomment
>       test_compare<char>, test_length<char>, test_find<char>,
>       test_compare<wchar_t>, test_length<wchar_t> and test_find<wchar_t>
>       static_assert tests.
> 
> Modified:
>     branches/gcc-7-branch/libstdc++-v3/ChangeLog
>     branches/gcc-7-branch/libstdc++-v3/doc/html/manual/status.html
>     branches/gcc-7-branch/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
>     branches/gcc-7-branch/libstdc++-v3/include/bits/char_traits.h
>    
> branches/gcc-7-branch/libstdc++-v3/testsuite/21_strings/char_traits/
> requirements/constexpr_functions_c++17.cc

Did these fix it?

Reply via email to