public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
@ 2005-10-10 19:39 ` ian at airs dot com
  2005-10-10 19:44 ` mark at codesourcery dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2005-10-10 19:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from ian at airs dot com  2005-10-10 19:39 -------
I think Mark's analysis is somewhat misleading for this particular warning,
since this warning actually is issued by the frontend.  It comes from
convert_to_void in cp/cvt.c.


-- 

ian at airs dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ian at airs dot com


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
  2005-10-10 19:39 ` [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects ian at airs dot com
@ 2005-10-10 19:44 ` mark at codesourcery dot com
  2005-10-11 22:34 ` mark at codesourcery dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mark at codesourcery dot com @ 2005-10-10 19:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from mark at codesourcery dot com  2005-10-10 19:44 -------
Subject: Re:  [3.4/4.0/4.1 regression] Templates/non-templates
 and warnings about statements without effects

ian at airs dot com wrote:
> ------- Comment #10 from ian at airs dot com  2005-10-10 19:39 -------
> I think Mark's analysis is somewhat misleading for this particular warning,
> since this warning actually is issued by the frontend.  It comes from
> convert_to_void in cp/cvt.c.

Oh, dear.  Yes, I agree; if the warning is coming from the front-end, it
must be the front-end's responsibility to fix, and my opinions about
warnings from the middle end are not relevant.


-- 


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
  2005-10-10 19:39 ` [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects ian at airs dot com
  2005-10-10 19:44 ` mark at codesourcery dot com
@ 2005-10-11 22:34 ` mark at codesourcery dot com
  2005-10-11 22:37 ` ian at airs dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mark at codesourcery dot com @ 2005-10-11 22:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from mark at codesourcery dot com  2005-10-11 22:33 -------
Subject: Re:  [3.4/4.0/4.1 regression] Templates/non-templates
 and warnings about statements without effects

With the proposed patch, what happens with something like:

template <typename T>
void f() {
  T(); /* Has side-effects only if T is a class type.  */
}

In general, I'm concerned about warning only at template-declaration
time because I don't think we can be sure we can see all side effects at
that point.  I think it would be more reliable (and more consistent with
the overall approach in G++) to warn only in the instantiations.


-- 


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2005-10-11 22:34 ` mark at codesourcery dot com
@ 2005-10-11 22:37 ` ian at airs dot com
  2005-10-11 22:46 ` mark at codesourcery dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2005-10-11 22:37 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 533 bytes --]



------- Comment #13 from ian at airs dot com  2005-10-11 22:37 -------
With your suggested test case, and my suggested patch, you will get the warning

foo.cc: In function ‘void f()’:
foo.cc:3: warning: value computed is not used

It's easy to emit the warning only for template instantiations and not for
template declarations.  That wasn't my first choice because it means that you
will get a warning each time the template is instantiated.

I will submit a new patch.


-- 


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2005-10-11 22:37 ` ian at airs dot com
@ 2005-10-11 22:46 ` mark at codesourcery dot com
  2005-10-11 23:27 ` mark at codesourcery dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mark at codesourcery dot com @ 2005-10-11 22:46 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 923 bytes --]



------- Comment #14 from mark at codesourcery dot com  2005-10-11 22:46 -------
Subject: Re:  [3.4/4.0/4.1 regression] Templates/non-templates
 and warnings about statements without effects

ian at airs dot com wrote:
> ------- Comment #13 from ian at airs dot com  2005-10-11 22:37 -------
> With your suggested test case, and my suggested patch, you will get the warning
> 
> foo.cc: In function ‘void f()’:
> foo.cc:3: warning: value computed is not used
> 
> It's easy to emit the warning only for template instantiations and not for
> template declarations.  That wasn't my first choice because it means that you
> will get a warning each time the template is instantiated.

Yes, that's annoying -- but I think it's more accurate overall.

You should also feel free to argue with me; I'm not trying to be a dictator.

> I will submit a new patch.

Thanks.


-- 


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2005-10-11 22:46 ` mark at codesourcery dot com
@ 2005-10-11 23:27 ` mark at codesourcery dot com
  2005-10-11 23:31 ` cvs-commit at gcc dot gnu dot org
  2005-10-11 23:33 ` ian at airs dot com
  7 siblings, 0 replies; 8+ messages in thread
From: mark at codesourcery dot com @ 2005-10-11 23:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from mark at codesourcery dot com  2005-10-11 23:27 -------
Subject: Re:  [3.4/4.0/4.1 regression] Templates/non-templates
 and warnings about statements without effects

This patch is OK, thanks!


-- 


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2005-10-11 23:27 ` mark at codesourcery dot com
@ 2005-10-11 23:31 ` cvs-commit at gcc dot gnu dot org
  2005-10-11 23:33 ` ian at airs dot com
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-11 23:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from cvs-commit at gcc dot gnu dot org  2005-10-11 23:31 -------
Subject: Bug 8057

CVSROOT:        /cvs/gcc
Module name:    gcc
Changes by:     ian@gcc.gnu.org 2005-10-11 23:30:57

Modified files:
        gcc/cp         : ChangeLog cvt.c 
        gcc/testsuite  : ChangeLog 
        gcc/testsuite/g++.dg/warn: noeffect2.C noeffect4.C 
Added files:
        gcc/testsuite/g++.dg/warn: noeffect7.C 

Log message:
        cp/
        PR c++/8057
        * cvt.c (convert_to_void): Don't warn about unused values when
        processing a template declaration.
        testsuite/
        PR c++/8057
        * g++.dg/warn/noeffect7.C: New test.
        * g++.dg/warn/noeffect2.C: Instantiate templates.
        * g++.dg/warn/noeffect4.C: Instantiate template.  Add new error
        and warning.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4920&r2=1.4921
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cvt.c.diff?cvsroot=gcc&r1=1.187&r2=1.188
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6169&r2=1.6170
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/noeffect7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/noeffect2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/noeffect4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2


-- 


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


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

* [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects
       [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2005-10-11 23:31 ` cvs-commit at gcc dot gnu dot org
@ 2005-10-11 23:33 ` ian at airs dot com
  7 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2005-10-11 23:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from ian at airs dot com  2005-10-11 23:33 -------
Fixed on mainline.  I don't think there is any compelling need to backport this
minor warning patch to the 4.0 or 3.4 branches.


-- 

ian at airs dot com changed:

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


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


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

end of thread, other threads:[~2005-10-11 23:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-8057-180@http.gcc.gnu.org/bugzilla/>
2005-10-10 19:39 ` [Bug c++/8057] [3.4/4.0/4.1 regression] Templates/non-templates and warnings about statements without effects ian at airs dot com
2005-10-10 19:44 ` mark at codesourcery dot com
2005-10-11 22:34 ` mark at codesourcery dot com
2005-10-11 22:37 ` ian at airs dot com
2005-10-11 22:46 ` mark at codesourcery dot com
2005-10-11 23:27 ` mark at codesourcery dot com
2005-10-11 23:31 ` cvs-commit at gcc dot gnu dot org
2005-10-11 23:33 ` ian at airs dot com

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).