[Bug c++/6730] Crash involving templates when compiling program
giovannibajo at libero dot it
gcc-bugzilla@gcc.gnu.org
Wed Jun 25 17:58:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6730
------- Additional Comments From giovannibajo at libero dot it 2003-06-25 16:56 -------
---------------------------------------
template <int>
struct Bar {};
template <typename T>
struct Foo
{
template <class U>
int foo( Bar<sizeof(U::x)>* );
};
template struct Foo<int>;
---------------------------------------
During instantiation of Foo, we tsusbt the declarations of the member template
functions (tsubst_decl, case FUNCTION_DECL), because this is needed to be able
to unify/call them.
But when we tsubst the function type and the arguments we fail to realize that
we are not *instantiating* them, but simply replacing the argument. Thus, the
build_*() functions do try to perform semantic checks and they crash because
the types of the (dependent) expressions.
A quick hack is to set processing_template_decl around the two tsubst calls for
the function type and the arguments. This makes the code compile, but the
intent of the original poster (using SFINAE to detect the presence of a member
operator[]) will still not work, since SFINAE is not fully implemented yet.
More information about the Gcc-bugs
mailing list