This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37225] New: Incorrect intantiation context yields incorrect codegen
- From: "gdr at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Aug 2008 23:28:13 -0000
- Subject: [Bug c++/37225] New: Incorrect intantiation context yields incorrect codegen
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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