🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1014

g++ 2.2.2 template syntax error

#1014
From: Philippe F. Bertrand
Date: Thu, 01 Oct 1992 18:42
89 lines
2058 bytes
In my opinion, the base class initialization is correct in version 3
but not in version 2 yet version 1 fails to compile.

VERSION 1
=========

template < int b >
class C {
     int B;
   public:
   C( int cc );
};

template < int b > C<b>::C( int cc ) {
  B = b * cc;
  printf( "%d\n", B );
}

class Foo : public C<7> {

    public:
	int X;

	Foo( int xx );
};

Foo::Foo( int xx )
 : C( 2 )
{
  X = xx;
}

void test( ) {

  Foo bar(123);

}

----------------------
junk.c: In method `Foo::Foo (int)':
junk.c:23: class `Foo' does not have any field named `C'
junk.c:24: too few arguments for constructor `C'
junk.c:24: in base initialization for class `Foo'
junk.c: In method `C<7>::C (int)':
junk.c:11: warning: implicit declaration of function `printf'


VERSION 2
=========

template < int b >
class C {
     int B;
   public:
   C( int cc );
};

template < int b > C<b>::C( int cc ) {
  B = b * cc;
  printf( "%d\n", B );
}

class Foo : public C<7> {

    public:
	int X;

	Foo( int xx );
};

Foo::Foo( int xx )
 : C<7>( 2 )
{
  X = xx;
}

void test( ) {

  Foo bar(123);

}

--------------------------
junk.c: In method `C<7>::C (int)':
junk.c:11: warning: implicit declaration of function `printf'

- Philippe F. Bertrand                          pfbertrand@watcgl.uwaterloo.ca 
Computer Graphics Lab, Department of Computer Science,
University of Waterloo, Waterloo, Canada  N2L 3G1
Technical Details
Message-ID: <BvGHAu.4KG@watcgl.uwaterloo.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!constellation!convex!convex!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!usc!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!watcgl.uwaterloo.ca!pfbertra

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!constellation!convex!convex!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!usc!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!watcgl.uwaterloo.ca!pfbertra
From: pfbertra@watcgl.uwaterloo.ca (Philippe F. Bertrand)
Subject: g++ 2.2.2 template syntax error
Message-ID: <BvGHAu.4KG@watcgl.uwaterloo.ca>
Sender: gnulists@ai.mit.edu
Organization: Computer Graphics Lab [CGL], University of Waterloo
Distribution: gnu
Date: Thu, 1 Oct 1992 18:42:17 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 90