g++(3.x) complains about incomplete type while it shouldn't

Peter Soetens peter.soetens@mech.kuleuven.ac.be
Tue Feb 1 21:02:00 GMT 2005


The code below compiles fine with Intel's icc. However,
all gcc versions refused to compile it saying :

g++    -c -o ttt.o ttt.cpp
ttt.cpp: In instantiation of `Property<F>':
ttt.cpp:15:   instantiated from `bool Property<T>::change(PropOp*) [with T = 
ttt.cpp:23:   instantiated from here
ttt.cpp:13: error: `Property<T>::val' has incomplete type
ttt.cpp:1: error: forward declaration of `struct F'

struct F;

template< class T >
struct Property;

struct PropOp {
    bool update( Property<F>*      f) { return false; }
    bool update( Property<double>* d) { return true; }

template<class T>
struct Property {
    T val;
    bool change( PropOp* p) {
        return p->update( this );  // Line 15

int main()
    PropOp po;
    Property<double> pd;           // Line 23
    pd.change( &po );
    return 0;


May I submit this as a bug ? I believe Property<F> should not be instantiated 
in line 15, only Property<double> should be.


PS: Please CC me.

Peter Soetens, Research Assistant                  http://www.orocos.org
Katholieke Universiteit Leuven
Division Production Engineering,                      tel. +32 16 322773
Machine Design and Automation                         fax. +32 16 322987
Celestijnenlaan 300B                   peter.soetens@mech.kuleuven.ac.be
B-3001 Leuven Belgium                 http://www.mech.kuleuven.ac.be/pma

More information about the Gcc-help mailing list