The program snippet below shows that GCC/g++ uses an incorrect
instantiation context leading to program miscompilation.
In particular, there is only one instantiation context for g(),
and in that instantiation context, the second f() is inexistant
therefore should not be considered.
#include <iostream>
namespace N {
class A { };
char f(A, int) { return 'a'; }
}
template<class T, class T2> char g(T t, T2 t2){return f(t, t2);}
char c = g(N::A(), 'a');
namespace N {
int f(A, char c){ return c+1;}
}
int main() {
std::cout << c << std::endl;
}
-- Gaby
--
Summary: Incorrect intantiation context yields incorrect codegen
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gdr at gcc dot gnu dot org
GCC host triplet: platform independent
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37225