cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[dcl.link] p5 The extent of the ignore for class member #368

Closed xmh0511 closed 1 year ago

xmh0511 commented 1 year ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[dcl.link] p5 says:

A C language linkage is ignored in determining the language linkage of class members, friend functions with a trailing requires-clause, and the function type of non-static class member functions.

Consider this example:

extern "C"{
   class A{
     static void fun(){}
  };
}

A::fun is a static member function, however, it is not clear how the extent "A C language linkage is ignored in determining the language linkage of class members" intends to apply. Does it only ignore the language linkage for the name of the class member, or both name and its type if it is a member function? The same issue exists for the friend functions.

Suggested Resolution

The intent may be:

A C language linkage is ignored in determining the language linkage of the names of class members, friend functions with a trailing requires-clause, and the function type of non-static class member functions.

This means, for the static member function and friend function, their names keep the C++ language linkage but their types are affected by the C language linkage.

frederick-vs-ja commented 1 year ago

The intent seems to be same as CWG2483 which is already resolved.

jensmaurer commented 1 year ago

[dcl.link] p1 clearly describes the categories to which language linkage applies: functions, variables, function types. (The former two are understood to refer to the names.)

I think the phrasing in [dcl.link] p5 parallels the one in p1: function types are separated out from "class members and friend functions", which are in the non-function type category per p1.

Note that we never say that a "name" has language linkage; an entity has.

I'm not seeing a defect, and in particular the suggested resolution is worsening the situation.