http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49153
Summary: Compile error with template metafunctions (starting
with 4.5.x)
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: di...@roedu.net
Hi,
Starting with g++ 4.5.x this code does not compile anymore:
struct NullType;
template
struct TypeList {
typedef T head;
typedef U tail;
};
template class MetaFunction>
struct MetaBind1st {
template
struct type: MetaFunction {};
};
template
struct AppendTypeListHelper {
typedef Elem type;
};
template
struct AppendTypeListHelper {
typedef TypeList type;
};
template
struct AppenderTypeList
{
template
struct Function: MetaBind1st::template type
{};
};
template
struct Visitor;
template
struct Visitor< TypeList > {};
struct Test {};
template struct Visitor::Function::type>;
$ g++ file.cc -c -o /dev/null
file.cc:43:17: error: explicit instantiation of 'struct
Visitor::type >' before
definition of template
The error seems to be related to an issue where g++ (>=4.5.x) stops evaluating
"AppenderTypeList::Function::type" to "TypeList" (at least it doesn't evaluate it as such when looking for a
specialization of "Visitor" and thus it errors that it can't instantiate the
general "Visitor" that is incompletely defined).
It compiles fine with g++ < 4.5.x. Also, if I rename the nested struct "type"
from MetaBind1st to be called "Function" (and update its use from
AppenderTypeList) it compiles with g++ >= 4.5.x too.
I don't understand what the naming of that field has anything to do with the
code compiling or not.
Thanks!