http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47940

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-01 
12:30:06 UTC ---
(In reply to comment #0)
> 
> Functions that call pure virtual functions cannot
> be called from constructors and destructors.
> This may be discovered at compile-time, and the above
> text makes a good error/warning message.

I'm not sure it makes a good diagnostic, consider:

struct abc {
  abc(bool nasal_demons) { if (nasal_demons) fly(); }
  void fly() { doFly(); }
  virtual void doFly() = 0;
};

Ideally the diagnostic for this would say "may call a pure virtual" for cases
where it can't be determined.

But then I don't really like the current diagnostic for direct calls either:

warning: abstract virtual 'virtual void abc::doFly()' called from constructor

I don't like the duplication of the word "virtual" and I don't like the term
"abstract virtual" - the class is abstract, the function is pure virtual.

Reply via email to