public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13077] New: Need a way to disable warnings in code
@ 2003-11-16 17:28 tron dot thomas at verizon dot net
  2003-11-16 17:58 ` [Bug c++/13077] " bangerth at dealii dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: tron dot thomas at verizon dot net @ 2003-11-16 17:28 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
@ 2003-11-16 17:58 ` bangerth at dealii dot org
  2003-11-16 18:23 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2003-11-16 17:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2003-11-16 17:58 -------
What's wrong with 
  -Wno-ctor-dtor-privacy 
in this case? 
 
W. 

-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
  2003-11-16 17:58 ` [Bug c++/13077] " bangerth at dealii dot org
@ 2003-11-16 18:23 ` pinskia at gcc dot gnu dot org
  2003-11-16 21:45 ` tron dot thomas at verizon dot net
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-16 18:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-16 18:23 -------
This is good improvement.
But in this case since it is already a flag, just use that flag.
I thought I saw a dup of this bug before but I cannot find it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-11-16 18:23:01
               date|                            |


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
  2003-11-16 17:58 ` [Bug c++/13077] " bangerth at dealii dot org
  2003-11-16 18:23 ` pinskia at gcc dot gnu dot org
@ 2003-11-16 21:45 ` tron dot thomas at verizon dot net
  2003-11-16 21:51 ` tron dot thomas at verizon dot net
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tron dot thomas at verizon dot net @ 2003-11-16 21:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tron dot thomas at verizon dot net  2003-11-16 21:45 -------
Subject: Re:  Need a way to disable warnings in code

Using -Wno-ctor-dtor-privacy will certainly work for the case I 
described.  It's still not ideal as it may be difficult to apply it only 
when needed for a project that is more complicated.

Development tools like Project Builder for Mac OS X using GCC as its 
compiler.  Project Builder does not use make files, and there is no way 
to apply a certain compiler flag to a specific module.  This means I 
cannot modify a make file to app -Wno-ctor-dtor-privacy for particular 
modules that would cause an invalid warning.  I can only apply it 
globally to all modules built by the project.  This isn't desirable.  I 
would like to warning to be effective in cases where it would be valid.

Being able to disable the warning within the source code allows for the 
granularity needed to disable the warning only for areas where the 
warning should not apply.

bangerth at dealii dot org wrote:

>------- Additional Comments From bangerth at dealii dot org  2003-11-16 17:58 -------
>What's wrong with 
>  -Wno-ctor-dtor-privacy 
>in this case? 
> 
>W. 
>
>  
>




-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
                   ` (2 preceding siblings ...)
  2003-11-16 21:45 ` tron dot thomas at verizon dot net
@ 2003-11-16 21:51 ` tron dot thomas at verizon dot net
  2003-11-16 22:43 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tron dot thomas at verizon dot net @ 2003-11-16 21:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tron dot thomas at verizon dot net  2003-11-16 21:51 -------
Subject: Re:  Need a way to disable warnings in code

Well. the case I present was obviously a contrived example for 
demonstration purposes.  The HeapObject class doesn't do anything except 
allow the use to delete objects allocated on the heap, and that's not 
useful for much of anything.

The real problem I'm having is that development tools like Project 
Builder for Mac OS X using GCC as its compiler.  Project Builder does 
not use make files, and there is no way to apply a certain compiler flag 
to a specific module.  This means I cannot modify a make file to app 
-Wno-ctor-dtor-privacy for particular modules that would cause an 
invalid warning.  I can only apply it globally to all modules built by 
the project.  This isn't desirable.  I would like to warning to be 
effective in cases where it would be valid.

Being able to disable the warning within the source code allows for the 
granularity needed to disable the warning only for areas where the 
warning should not apply.

I don't really consider what I logged into the database as a bug per 
se.  It is more of a feature request that I feel will improve the 
quality of the GCC compiler.

pinskia at gcc dot gnu dot org wrote:

>------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-16 18:23 -------
>This is good improvement.
>But in this case since it is already a flag, just use that flag.
>I thought I saw a dup of this bug before but I cannot find it.
>
>  
>




-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
                   ` (3 preceding siblings ...)
  2003-11-16 21:51 ` tron dot thomas at verizon dot net
@ 2003-11-16 22:43 ` pinskia at gcc dot gnu dot org
  2003-11-17  0:10 ` tron dot thomas at verizon dot net
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-16 22:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-16 22:43 -------
What you said about "Project Builder" is not true, it has not been true for the past year.
Yes it is hard to find where to put per file flags but you can do it.
Go to the target settings.
Click on Sources under "Build Phase".
Click on the file you want to add the flag.
Click on the left most part of the field and this will bring up a window where you can put the extra 
flag.

-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
                   ` (4 preceding siblings ...)
  2003-11-16 22:43 ` pinskia at gcc dot gnu dot org
@ 2003-11-17  0:10 ` tron dot thomas at verizon dot net
  2003-11-17 15:33 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tron dot thomas at verizon dot net @ 2003-11-17  0:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tron dot thomas at verizon dot net  2003-11-17 00:10 -------
Subject: Re:  Need a way to disable warnings in code

Thanks pinskia.  I did not know about that.  I'm glad there is a way to 
deal with per module settings.
I still don't know how helpful it is because the warning is actually 
generated in a header file, and knowing all the module that would be 
affected by the header is a little tricky.
I've dealt with the problem by stubbing an extra, unnecessary function 
into class that will eliminate the warning when building with GCC.  This 
will work fine for me.

pinskia at gcc dot gnu dot org wrote:

>------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-16 22:43 -------
>What you said about "Project Builder" is not true, it has not been true for the past year.
>Yes it is hard to find where to put per file flags but you can do it.
>Go to the target settings.
>Click on Sources under "Build Phase".
>Click on the file you want to add the flag.
>Click on the left most part of the field and this will bring up a window where you can put the extra 
>flag.
>
>  
>




-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
                   ` (5 preceding siblings ...)
  2003-11-17  0:10 ` tron dot thomas at verizon dot net
@ 2003-11-17 15:33 ` bangerth at dealii dot org
  2003-11-17 15:46 ` pinskia at gcc dot gnu dot org
  2003-11-19  4:31 ` gdr at integrable-solutions dot net
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2003-11-17 15:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2003-11-17 15:32 -------
Regarding your general request of something like
  #pragma warning off ctor-dtor-privacy
I'm sure we're all with you. This has been discussed several times on
the mailing lists, but nobody has volunteered to implement it. Since
gcc is a volunteer project, that's what it would take, unless someone
steps forward and wants to pay somebody for doing it.

W.

-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
                   ` (6 preceding siblings ...)
  2003-11-17 15:33 ` bangerth at dealii dot org
@ 2003-11-17 15:46 ` pinskia at gcc dot gnu dot org
  2003-11-19  4:31 ` gdr at integrable-solutions dot net
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-17 15:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-17 15:46 -------
This is a dup of bug 9049, the other one asking for a way to disable warnings in code.

*** This bug has been marked as a duplicate of 9049 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13077] Need a way to disable warnings in code
  2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
                   ` (7 preceding siblings ...)
  2003-11-17 15:46 ` pinskia at gcc dot gnu dot org
@ 2003-11-19  4:31 ` gdr at integrable-solutions dot net
  8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-11-19  4:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2003-11-19 04:31 -------
Subject: Re:  Need a way to disable warnings in code

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| ------- Additional Comments From bangerth at dealii dot org  2003-11-17 15:32 -------
| Regarding your general request of something like
|   #pragma warning off ctor-dtor-privacy

Please let not do there again.

| I'm sure we're all with you.

I, for one, am not with you.  When discussing #dogmas, please do
carefully consider how they interact with language features.

-- Gaby


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-11-19  4:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-16 17:28 [Bug c++/13077] New: Need a way to disable warnings in code tron dot thomas at verizon dot net
2003-11-16 17:58 ` [Bug c++/13077] " bangerth at dealii dot org
2003-11-16 18:23 ` pinskia at gcc dot gnu dot org
2003-11-16 21:45 ` tron dot thomas at verizon dot net
2003-11-16 21:51 ` tron dot thomas at verizon dot net
2003-11-16 22:43 ` pinskia at gcc dot gnu dot org
2003-11-17  0:10 ` tron dot thomas at verizon dot net
2003-11-17 15:33 ` bangerth at dealii dot org
2003-11-17 15:46 ` pinskia at gcc dot gnu dot org
2003-11-19  4:31 ` gdr at integrable-solutions dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).