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

            Bug ID: 125663
           Summary: [reflection] Reflecting a conversion-function-id of a
                    conversion function template yields a reflection of
                    the template, but it should yield the named
                    specialization
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

https://gcc.godbolt.org/z/sMbE3zo7W
====
#include <meta>

struct A {
    template<class T>
    operator T();
};

constexpr auto r = ^^A::operator int;
static_assert(std::meta::is_function(r));

====
<source>:9:37: error: static assertion failed
    9 | static_assert(std::meta::is_function(r));
      |               ~~~~~~~~~~~~~~~~~~~~~~^~~

====
It appears that GCC finds the name `operator int` in `^^A::operator int` to
correspond to a function template, and yields a reflection of that template.
This behavior makes sense if the name were an identifier, but here the name is
a conversion-function-id.

Since a conversion-function-id is not a *reflection-name* and is a
*id-expression*, the *reflect-expression* should be subject to
[expr.reflect]/7, which says that:

> if the id-expression denotes an overload set S, overload resolution for the
> expression &S with no target shall select a unique function ([over.over]);
> R represents that function.

That is, the result of `^^A::operator int` should represent a function, not a
function template.

Reply via email to