This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: fatal template bug


On Mon, 5 Apr 1999, Paul Blattner wrote:

> As a result of a compiler problem, the Egcs 1.1.2 (Mingw32 version)
> caused a fatal compiler error in compiliing my pins.cc file.
> 
> The command line used was gcc -c -fshort-enums pins.cc

It crashes on other platforms as well, and with or without the
-fshort-enums flag.

The problem is that your table<> class needs to define const_iterator,
and defining that fixes it. However, the compiler should flag the error
instead of dying, so it's definitely a bug.

The development snapshots do the right thing however, so looks like
it'll be fixed in 1.2 release whenever that comes out.

  In file included from pins.cc:1:
  token.h:72: ANSI C++ forbids declaration `line' with no type
  token.h:77: ANSI C++ forbids declaration `fileno' with no type
  pins.cc:161: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:162: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:163: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:164: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:586: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:592: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:597: ANSI C++ forbids declaration `write_param' with no type
  pins.cc:602: ANSI C++ forbids declaration `write_param' with no type
  table.h: In method `class pin * table<token *,pin *>::find(class token *)
  const':
  pins.cc:213:   instantiated from here
  table.h:56: variable `typename rb_tree<token *,pair<token *const,pin
  *>,select1st<pair<token *const,pin *> >,Compare,Alloc>::const_iterator
  found' has initializer but incomplete type
  pins.cc:213:   instantiated from here
  table.h:62: confused by earlier errors, bailing out

> I would appreciate any information about this bug, especially
> a work-around, if one is available.

Workaround is to fix your code. When you derive from a standard container,
you typically always need to define the usual stuff such as iterators and
all that. Wasn't there a GOTW (Guru of the Week) article on this a while
back (http://www.peerdirect.com/)? Perhaps I'm thinking about Bruce
Eckel's on-line "Thinking in C++" book (http://www.bruceeckel.com/)?

Here's one hint:
  
  template<class I, class T>
  class table: public map<I, T, less<I> >
  {
  public:
    typedef  map<I, T, less<I> > base;
    typedef base::const_iterator const_iterator;
  
  public:
    // rest of your stuff.
  };


While you're at it, you should also fix the non-ANSI declarations (hint:
type is not assumed to be ``int'' if it's omitted).

Regards,
Mumit




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]