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

D <dragondreamer at live dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dragondreamer at live dot com

--- Comment #8 from D <dragondreamer at live dot com> ---
This bug is not still yet for __PRETTY_FUNCTION__. The sample code below does
not compile even with GCC 7 (however, works fine in Clang).

//////////////

constexpr bool str_equal(const char* s1, const char* s2) noexcept
{
   return !*s1 && !*s2 ? true
    : !*s1 ? false
    : !*s2 ? false
    : *s1 == *s2 ? str_equal(s1 + 1, s2 + 1)
    : false;
}

int main()
{
    static_assert(str_equal(__PRETTY_FUNCTION__, "int main()"), "test");
}


//////////////



<source>: In function 'int main()':
<source>:12:5: error: non-constant condition for static assertion
     static_assert(str_equal(__PRETTY_FUNCTION__, "int main()"), "test");
     ^~~~~~~~~~~~~
<source>:12:28:   in constexpr expansion of 'str_equal(((const char*)(&
__PRETTY_FUNCTION__)), ((const char*)"int main()"))'
<source>:12:5: error: the value of '__PRETTY_FUNCTION__' is not usable in a
constant expression
<source>:12:29: note: '__PRETTY_FUNCTION__' was not declared 'constexpr'
     static_assert(str_equal(__PRETTY_FUNCTION__, "int main()"), "test");
                             ^~~~~~~~~~~~~~~~~~~
Compiler exited with result code 1

Reply via email to