This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1981: using declarations in function templates



>Number:         1981
>Category:       c++
>Synopsis:       using declarations in function templates
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 14 07:36:02 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Sylvain Pion
>Release:        2.97 20010212 (experimental)
>Organization:
>Environment:
System: Linux zosma 2.2.14 #1 SMP Fri Jan 14 14:39:36 MET 2000 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /u/zosma/0/prisme/spion/gcc/gcc/configure --enable-languages=c++ --prefix=/u/zosma/0/prisme/spion/gcc/Linux_CVS_v3
>Description:

The following code doesn't compile (both 2.95.2, and 3.0 branch).
It gives :

test.C: In function `void f(T) [with T = int]':
test.C:18:   instantiated from here
test.C:13: `swap' undeclared (first use this function)
test.C:13: (Each undeclared identifier is reported only once for each
   function it appears in.)

Note 1 : it works when f() is not template.

Note 2 : if A == std (my original case in fact), then it works with g++ 2.95.2,
         but not 3.0 !  So it's a regression.

	
>How-To-Repeat:

namespace A {
template <class T>
void swap(T& a, T& b) {
  T tmp = a; a = b; b = tmp;
}
};

template <class T>
void f(T) {
  using A::swap;
  int i,j;
  swap(i,j);
}

int main() {
  f(1);
}
	
>Fix:

A workaround consists in calling A::swap() directly.

	
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]