Title
C language linkage and constrained non-template friends
Status
cd6
Section
9.11 [dcl.link]
Submitter
Hubert Tong

Created on 2020-03-23.00:00:00 last changed 27 months ago

Messages

Date: 2020-04-15.00:00:00

Proposed resolution (April, 2020):

Change 9.11 [dcl.link] paragraph 5 as follows:

...A C language linkage is ignored in determining the language linkage of the names of class members, the names of friend functions with a trailing requires-clause, and the function type of class member functions...
Date: 2020-11-15.00:00:00

[Accepted at the November, 2020 meeting.]

According to 13.7.5 [temp.friend] paragraph 9,

A non-template friend declaration with a requires-clause shall be a definition. A friend function template with a constraint that depends on a template parameter from an enclosing template shall be a definition. Such a constrained friend function or function template declaration does not declare the same function or function template as a declaration in any other scope.

However, this specification conflicts with the treatment of functions with C language linkage in 9.11 [dcl.link] paragraph 7:

At most one function with a particular name can have C language linkage. Two declarations for a function with C language linkage with the same function name (ignoring the namespace names that qualify it) that appear in different namespace scopes refer to the same function.

For example:

  template <typename T> struct A { struct B; };

  extern "C" {
  template <typename T>
  struct A<T>::B {
   friend void f(B *) requires true {} // C language linkage applies
  };
  }

  namespace Q {
   extern "C" void f(); // ill-formed redeclaration?
  }
History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: drwp -> cd6
2021-02-24 00:00:00adminsetstatus: dr -> drwp
2020-12-15 00:00:00adminsetmessages: + msg6328
2020-03-23 00:00:00admincreate