This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2357. Lookup in member function declarations

Section: 6.5.3  [basic.lookup.unqual]     Status: NAD     Submitter: John Spicer     Date: 2017-09-07

Consider an example like the following:

  template <typename T>
  void doit(const T& t, const T& t2) { }

  template <typename T>
  struct Container {
    auto doit(Container<T> &rhs)
    noexcept(noexcept(doit(T{}, T{})))
       -> decltype(doit(T{}, T{}));
  };

  Container<int> c;

This would appear to be ill-formed because the exception specification is a delayed-parse region, where the lookup is in the context of the completed class, while the lookup in the decltype in the return type is done immediately. The latter should find the two-parameter version of doit, as expected, while the former finds the member, one-parameter version. Current implementations accept the code, however, and it seems unfortunate that the meaning would be different in the two contexts.

Rationale, June, 2018:

The example is ill-formed: the reference to doit in the return type would refer to the member function in the completed class, which is ill-formed, no diagnostic required, per 6.4.7 [basic.scope.class] paragraph 2.