bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

warnings that shouldn't be


From: Kenton Varda
Subject: warnings that shouldn't be
Date: Mon, 19 Mar 2001 07:00:27 -0600

This is a rather low-priority bug, but I thought I'd mention it, as it
has been bothering me quite a bit lately.

g++ has a warning that goes something like this:

warning: `class MyClass' only defines private constructors and has no
friends

I don't believe that this warning should exist.  First of all, if the
coder has, in fact, screwed up, they are likely to notice it very
quickly anyway.  So, the warning doesn't help much.

Secondly, there are many C++ coding techniques in which the coder
intentionally defines all constructors as private.  In my case, I have
static functions which must be called to allocate my classes, and the
constructors are declared private to force clients to use the static
functions.  Another case where the warning shows up is when a class only
contains static members, and the author declares the constructor as
private to prevent clients from inadvertently instantiating the class.

I know there is probably some way to disable the warning (which I am too
lazy to find :).  But I still think it should be removed altogether.


On an unrelated note, it would be nice to have a warning when there is a
possibility that a function will terminate by calling unexpected().
(that is, when it might throw an exception other than those it is
specified as throwing.)  This would help debugging quite a bit...
though it might be hard to implement.

Thanks!

-Kenton Varda




reply via email to

[Prev in Thread] Current Thread [Next in Thread]