Movatterモバイル変換


[0]ホーム

URL:


Issue 1309 - WG21 CWG Issues
Title
Incorrect note regarding lookup of a member of the current instantiation
Status
cd4
Section
13.8.3.2 [temp.dep.type]
Submitter
Johannes Schaub

Created on2011-05-05.00:00:00 last changed109 months ago

Messages

msg6059 (view)
Date: 2015-05-15.00:00:00

[Moved to DR at the May, 2015 meeting.]

msg5155 (view)
Date: 2014-11-15.00:00:00

Proposed resolution (November, 2014):

Change 13.8.3.2 [temp.dep.type] paragraph 7 as follows:

...If the result of this lookup differs from the resultof name lookup in the template definition context, namelookup is ambiguous.[Note: the result of namelookup differs only when the member of the currentinstantiation was found in a non-dependent base class of thecurrent instantiation and a member with the same name isalso introduced by the substitution for a dependent baseclass of the current instantiation. —endnote][Example:

  struct A {    int m;  };  struct B {    int m;  };  template<typename T>  struct C : A, T {    int f() { return this->m; }  // findsA::m in the template definition context  };  template int C<B>::f();        // error: finds bothA::m andB::m

end example]

msg3900 (view)
Date: 2011-12-15.00:00:00

Notes from the December, 2011 teleconference:

Changes to the exposition were suggested and the issue returned to"drafting" status.

msg3899 (view)
Date: 2011-08-15.00:00:00

Proposed resolution (August, 2011) [SUPERSEDED]:

Change 13.8.3.2 [temp.dep.type] paragraph 7 as follows:

...If the result of this lookup differs from the result of namelookup in the template definition context, name lookup isambiguous.[Note: the result of name lookup differs onlywhen the member of the current instantiation was found in anon-dependent base class of the current instantiation and a memberwith the same name is also introduced by the substitution for adependent base class of the current instantiation. —endnote][Example:

  struct A {    int m;  };  struct B {    int m;  };  template<typename T>  struct C : A, T {    int f() { return this->m; } // findsA::m in the template definition context  };  int g(C<B> cb) {    return cb.f();              // error: finds bothA::m andB::m in the template instantiation context  }

end example]

msg3507 (view)
Date: 2012-09-24.00:00:00

The note in 13.8.3.2 [temp.dep.type] paragraph 7 reads,

[Note: the result of name lookup differs only when the memberof the current instantiation was found in a non-dependent base classof the current instantiation and a member with the same name is alsointroduced by the substitution for a dependent base class of thecurrent instantiation. —end note]

However, this is not correct. Consider the following example:

  struct Y { int X; };  template<typename T>  struct A : Y {   enum B : int;   void f() { A::X; } // findsY::X here!  };  template<typename T>  enum A<T>::B : int {   X // introduces memberA::X intoA<T>!  };  void g() { A<int> a; a.f(); }

A::X is a member of the current instantiation, soparagraph 7 requires it to be looked up again when instantiating andto give a diagnostic if the lookup differs from the lookup in thedefinition context. The note incorrectly indicates that this can onlyhappen if the conflicting name was introduced by a dependent baseclass.

History
DateUserActionArgs
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-11-10 00:00:00adminsetstatus: dr -> drwp
2015-05-25 00:00:00adminsetmessages: +msg6059
2015-05-25 00:00:00adminsetstatus: ready -> dr
2014-11-24 00:00:00adminsetmessages: +msg5155
2014-11-24 00:00:00adminsetstatus: drafting -> ready
2012-09-24 00:00:00adminsetmessages: +msg3900
2012-09-24 00:00:00adminsetmessages: +msg3899
2012-01-17 00:00:00adminsetstatus: review -> drafting
2011-05-05 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp