
[Release a]
<t4m_bug_templincompl>
The compilation of the file templincompl.C,
template <int N>
class A {
int a[N];
public:
void operator << (int b) { a[0] = b; }
};
extern A<1> a;
int main(void) { a << 1; return 0; }
makes TenDRA complain like this
line 10: Error:
[ISO 5.8]: Operands of '<<' should be integral, not 'A < 1 >' and 'int'.
This also happens when ::a is a pointer to A<1>, and ceases when an object of
type A<1> is constructed before the call to operator <<. It is obvious that the
template class is not completely instantiated at the point where the compiler
is going to resolve the overload for operator <<.
The critical place seems to be inside the function overload_candidates (line
1083, operator.c). The call to the function search_field at line 1116 fails
because the CLASS_TYPE ct is neither defined (cinfo_defined is off) nor
complete (cinfo_complete is off). The way of completing a template class
instantiation is by calling complete_class (see instance.c, line 1354). Thus,
to fix this bug, one can change lines 1114 - 1116 of operator.c,
CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
NAMESPACE ns = DEREF_nspace ( ctype_member ( ct ) ) ;
IDENTIFIER id = search_field ( ns, nm, 0, 0 ) ;
for
CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
NAMESPACE ns ;
IDENTIFIER id ;
complete_class (ct, 1 ) ;
ns = DEREF_nspace ( ctype_member ( ct ) ) ;
id = search_field ( ns, nm, 0, 0 ) ;
and it works.