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

            Bug ID: 107904
           Summary: __func__ is not properly treated as an array variable
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Keywords: accepts-invalid, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

The following code is accepted by gcc from 4.7 to 12:

Godbolt link: https://godbolt.org/z/EYqh1f3oa

#include <type_traits>

void f()
{
    using T = decltype(__func__);
    T x = __func__;
    static_assert(std::is_lvalue_reference<T>::value, ""); // incorrectly
passes
    // static_assert(std::is_array<T>::value, ""); // incorrectly fails
}

It seems that gcc only treats __func__ as "an lvalue denoting an array object",
but not exactly "the array variable itself" specified in
[dcl.fct.def.general]/8.

Given there is an unresolved CWG issue 1962, this is possibly not a bug at this
moment. But it's unclear to me whether this is an intentional design.

Reply via email to