Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[namespace.udecl]/14 clarify wording for comparisons between templates and non-templates #3543

Open
cdacamar opened this issue Dec 13, 2019 · 4 comments
Labels
cwg Issue must be reviewed by CWG.

Comments

@cdacamar
Copy link

[namespace.udecl]/14 "... member functions and member function templates in the derived class override and/or hide member functions and member function templates ..."

We recently ran into a bug where we had this code:

template <typename>
struct Result { };

struct Base {
  template <typename T>
  Result<T> f(int) const;

  virtual Result<int> f(int) const = 0;
};

struct Derived : Base {
  virtual Result<int> f(int) const final;
  using Base::f;
};

struct S { };

void f() {
    Derived d;
    d.f<S>(0);
}

And I found wording of [namespace.udecl]/14 to be insufficient in distinguishing that we need to compare member functions and member function templates respectively. @GabrielDosReis had to help guide me to the correct interpretation.

Can this be addressed editorially?

@cdacamar
Copy link
Author

Note: Even if we compare them respectively we should add that a comparison of the template parameter lists should also be required.

@cdacamar
Copy link
Author

One more point is that there appears to be implementation divergence due to the existing wording:

template <typename>
struct Result { };

struct Base {
  template <typename T>
  Result<T> f(int) const;
};

struct Derived : Base {
  template <typename T, typename>
  Result<T> f(int) const;

  using Base::f;
};

struct S { };

void f() {
    Derived d;
    d.f<S>(0);
}

Clang will reject this code while gcc accepts: https://godbolt.org/z/Bu7h9z

@jensmaurer
Copy link
Member

jensmaurer commented Dec 14, 2019

The purpose of this rule is to avoid "using Base::f" to produce a conflicting declaration, and we poorly mimic the rules from [over.load] for that. For example, if the function from the base class has no ref-qualifier, but the (otherwise identical) function in the derived class has a ref-qualifier, is that ok? After all, [over.load] says such two declarations cannot appear in the a single class definition.

I'm not sure there is an editorial answer to that question.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Dec 14, 2019
@jensmaurer jensmaurer added cwg Issue must be reviewed by CWG. and removed decision-required A decision of the editorial group (or the Project Editor) is required. labels Feb 10, 2020
@jensmaurer
Copy link
Member

Editorial meeting: Not editorial, send to CWG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

2 participants