References to Template classes and user type conversions

Thomas E Deweese deweese@kodak.com
Tue Nov 2 12:54:00 GMT 1999


Hi all,

	I discovered a bug in the way user type conversions are handled
for references to template classes.  In the following example 'f3'
will fail to compile.  However, if you remove it (by defining 'WORK'),
f5 which is identical will compile.  Clearly something in the type
matching code is failing to expand user defined type conversions for
references to template types.  I know nothing of the internals of GCC
so I thought I would submit the bug in the hope that someone with more
clue would be able to help.

---------------------

template <class T>
struct X {
    operator bool() const;
};

struct Y { 
    operator bool() const;
};

void f1(const Y     x) { if (x) return; }
void f2(const Y    &x) { if (x) return; }

#ifndef WORK
void f3(const X<Y> &x) { if (x) return; } // fails if precedes 'f4'
#endif WORK

void f4(const X<Y>  x) { if (x) return; }
void f5(const X<Y> &x) { if (x) return; }


More information about the Gcc-bugs mailing list