public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32066]  New: member/type lookup doesn't work properly with templates
@ 2007-05-24 10:27 andrew dot stubbs at st dot com
  2009-12-07  8:13 ` [Bug c++/32066] " christian dot bruel at st dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: andrew dot stubbs at st dot com @ 2007-05-24 10:27 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]

The following is adapted from the example from the C++ standard, clause 14.6/4
(actually it's the updated version from DR345):

      1     struct A {
      2       struct X { };
      3       static int X; 
      4     } ; 
      5     template<class T> void f(T t) {
      6       typename T::X x;  // invalid
      7       T::X y;           // invalid
      8       int z = T::X;     // OK
      9     }
     10     void foo() {
     11       A a;   
     12       f(a);  // error: T::X refers to the data member A::X not 
     13              // the struct A::X.
     14     }

I've removed the `B' class from the example, made A::X static (so that T::X may
be used to reference it), and added lines 7 and 8. According to the standard,
clause 14.6/4, all the `T::X' should find the data member X, *not* the type
member X, regardless of the `typename' keyword.

In this case, however, GCC 4.1.1 has not done this, and gives the following
diagnostics:

t.cxx: In function ‘void f(T)’:
t.cxx:7: error: expected `;' before ‘y’

Line 6 has been compiled OK; `T::X' has found the type.
Line 7 has been rejected correctly; `T::X' has not found a type, which means
the `typename' keyword in line 6 was significant.
Line 8 has been compiled correctly; `T::X' has found the data member.


-- 
           Summary: member/type lookup doesn't work properly with templates
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot stubbs at st dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32066


^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <bug-32066-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-12-09  7:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-24 10:27 [Bug c++/32066] New: member/type lookup doesn't work properly with templates andrew dot stubbs at st dot com
2009-12-07  8:13 ` [Bug c++/32066] " christian dot bruel at st dot com
2009-12-07 15:11 ` redi at gcc dot gnu dot org
2009-12-07 16:41 ` christian dot bruel at st dot com
     [not found] <bug-32066-4@http.gcc.gnu.org/bugzilla/>
2021-12-09  2:25 ` pinskia at gcc dot gnu.org
2021-12-09  7:40 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).