------- Comment #5 from redi at gcc dot gnu dot org  2010-07-07 09:11 -------
(In reply to comment #3)
> > The answer is to
> > ensure the first, non-inline virtual function is defined. That's it.
>
> In my humble opinion, no it's not the answer, at least not in my, and I guess
> in many people's cases. I did not want to define it, but wanted to have a
> purely virtual function, without definition.

Well if you follow my rule you'd look at your class to see which is
the first non-inline virtual and you'd realise frob() isn't pure, and
be able to change that if that's what you want.

> Again, the wording is just a quick scratch, but your "answer which is it" is
> not necessarily the right solution either.

It's better to be able to fix the general case by following a simple
rule than to make the compiler enumerate all the possible ways a user
might have got it wrong.  The ways to write invalid code are almost
infinite.  There's often only one way to get it right.

> > Suggestions about "unintentionally becoming non-pure" would cause more
> > confusion than they would help.
>
> Well, it can be rephrased. Maybe something like "Did you intend to make it a
> pure virtual function? Add `= 0' then. Otherwise, ensure to define the
> function." would be the better solution.

I disagree.  It's far more common for this error to be caused by a
missing definition, or by having no non-inline virtuals, than a function which
is meant to be pure but has been declared wrong.

You've made a particular mistake and you're asking for the compiler to
be modified to tell you exactly what you need to change.  There are a
few different ways to get this error, I don't think yours is the most
common, so I don't think your suggestion is the right one.


-- 


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

Reply via email to