On 12/1/23 01:02, waffl3x wrote:
I ran into another issue while devising tests for redeclarations of
xobj member functions as static member functions and vice versa. I am
pretty sure by the literal wording of the standard, this is well formed.

template<typename T>
concept Constrain = true;

struct S {
   void f(this auto, Constrain auto) {};
   static void f(Constrain auto) {};

   void g(this auto const&, Constrain auto) {};
   static void g(Constrain auto) {};

   void h(this auto&&, Constrain auto) {};
   static void h(Constrain auto) {};
};

And also,

struct S{
   void f(this auto) {};
   static void f() {};

   void g(this auto const&) {};
   static void g() {};

   void h(this auto&&) {};
   static void h() {};
};

I wrote these tests expecting them to be ill-formed, and found what I
thought was a bug when they were not diagnosed as redecelarations.
However, given how the code for resolving overloads and determining
redeclarations looks, I believe this is actually well formed on a
technicality. I can't find the passages in the standard that specify
this so I can't be sure.

I think the relevant section is
https://eel.is/c++draft/basic.scope.scope

Anyway, the template parameter list differs because of the deduced
object parameter. Now here is the question, you are required to ignore
the object parameter when determining if these are redeclarations or
not, but what about the template parameters associated with the object
parameter? Am I just missing the passage that specifies this or is this
an actual defect in the standard?

I think that since they differ in template parameters, they don't correspond under https://eel.is/c++draft/basic.scope.scope#4.5 so they can be overloaded.

This is specified in terms of the template-head grammar non-terminal, but elsewhere we say that abbreviated templates are equivalent to writing out the template parameters explicitly.

The annoying thing is, even if this was brought up, I think the only
solution is to ratify these examples as well formed.

Yes.

Jason

Reply via email to