This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] Document pitfalls of two-stage name lookup, next revision
Wolfgang Bangerth writes:
+@example
+ void foo(double);
+
+ struct A @{
+ template <typename T>
+ void f () @{
+ foo (1); // 1
+ int i = N; // 2
+ T t;
+ t.bar(); // 3
+ foo (t); // 4
+ @}
+
+ static const int N;
+ @};
+@end example
+
+Here, the names @code{foo} and @code{N} appear in a context that does
+not depend on the type of @code{T}. The compiler will thus require that
+they are defined in the context of use in the template, not only before
+the point of instantiation, and will here use @code{::foo(double)} and
+@code{X::N}, respectively. In particular, it will convert the integer
+value to a @code{double} when passing it to @code{::foo(double)}.
Where is X::N coming from here? Should this be A::N?
--
Jonathan Lennox
lennox at cs dot columbia dot edu