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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
__builtin_strlen like many other string/memory builtins simply tries the
middle-end folding and gives up otherwise.  So if it is called on a string
literal, it is folded, but if it would require reading the bytes of the string
one by one, it will most likely fail.
This has been discussed in some other PR that we should have a helper that
allows constexpr.cc to read a single character and as fallback for the string
builtins call those in a loop and essentially evaluate the builtins as a
non-optimized trivial C++ implementation of those builtins.
I think std::strlen isn't constexpr even in latest C++, so all of this is
permitted by the standard...

Reply via email to