This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13077] New: Need a way to disable warnings in code
- From: "tron dot thomas at verizon dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Nov 2003 17:28:24 -0000
- Subject: [Bug c++/13077] New: Need a way to disable warnings in code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
A developer who wants to use the -Wall switch on GCC to be informed of all
potential code problems can encounter invalid warnings for perfectly valid code.
Consider this example:
class HeapObject
{
public:
void Delete() { delete this; }
private:
~HeapObject(){}
};
In this case the destructor for the class has been made private to prevent
instantiated object from being created on the stack, thus forcing all objects to
be allocated on the heap.
This code is perfectly valid, and the class is totally usable. The public
Delete method compensates for the private destructor. Compiling this code with
the -Wall switch will result in this warning:
warning: `class HeapObject' only defines a private destructor and has no friends
This warning is cause because -Wctor-dtor-privacy has been enabled through the
-Wall switch.
There is no reason that this warning shouldn't be enable in general. It is not
valid for this specific scenario and there should be a way to disable it.
The best way to solve this is to be able to disable the warning within the code
module that includes the code that causing the warning.
GCC should implement a feature to allow for this. Almost every other compiler
used in the industry support this capability, and it would be a very helpful
asset to GCC as well.
--
Summary: Need a way to disable warnings in code
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tron dot thomas at verizon dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13077