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

            Bug ID: 87399
           Summary: Inconsistent determination of what is usable in a
                    constant expression with __PRETTY_FUNCTION__
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Reduced from StackOverflow (https://stackoverflow.com/q/52472000/2069064):

template <int>
struct X { };

constexpr int f(char const *s)
{
    return *s;
}

void test()
{
    constexpr int i = f(__PRETTY_FUNCTION__);
    X<i> x;
    X<f(__PRETTY_FUNCTION__)> y;
}

gcc accepts the declaration of x and rejects the declaration of y. clang
accepts both. I am not sure, but based on my reading of [expr.const], since
__PRETTY_FUNCTION__ is not defined with constexpr, we run afoul of 2.7, and
both declarations of x and y should be rejected?

Either way, it seems like either both should be accepted or both should be
rejected.

Reply via email to