public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3662: Incorrect warnings with overridden virtual functions in template class
@ 2001-07-12 9:16 stuart
0 siblings, 0 replies; 2+ messages in thread
From: stuart @ 2001-07-12 9:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 3662
>Category: c++
>Synopsis: Incorrect warnings with overridden virtual functions in template class
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 12 09:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: stuart@personalrobots.com
>Release: gcc-3.0
>Organization:
>Environment:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc-3.0/configure --enable-threads
Thread model: posix
gcc version 3.0
>Description:
Compiling the attached file gives the following error:
test.cpp: In member function `TYPE CList<TYPE>::InvalidValue() [with TYPE =
int]':
test.cpp:11: instantiated from `TYPE CList<TYPE>::RemoveHead() [with TYPE = int]'
test.cpp:39: instantiated from here
test.cpp:14: warning: return to non-pointer type `int' from NULL
test.cpp:14: warning: argument to non-pointer type `int' from NULL
It seems to me that gcc is checking the wrong function and therefore emitting
an incorrect warning - stepping through the running program we never call
TYPE CList<TYPE>::InvalidValue(), only TYPE CTypeList<TYPE>::InvalidValue()
which is correct I believe.
>How-To-Repeat:
Compile the attached file with gcc-3.0
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cc"
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPHR5cGVuYW1lIFRZUEU+CiAgICBjbGFzcyBD
TGlzdAp7CiBwdWJsaWM6CiAgICBDTGlzdCgpIHt9OwogICAgdmlydHVhbCB+Q0xpc3QoKSB7fTsK
CiAgICBUWVBFIFJlbW92ZUhlYWQoKSB7IHJldHVybiBJbnZhbGlkVmFsdWUoKTsgfTsKCiAgICB2
aXJ0dWFsIFRZUEUgSW52YWxpZFZhbHVlKCkgeyByZXR1cm4gTlVMTDsgfTsKCiBwcml2YXRlOgp9
OwoKdGVtcGxhdGUgPHR5cGVuYW1lIFRZUEU+CiAgICBjbGFzcyBDVHlwZUxpc3QgOiBwdWJsaWMg
Q0xpc3Q8VFlQRT4KewogcHVibGljOgogICAgQ1R5cGVMaXN0KCkge307CiAgICB+Q1R5cGVMaXN0
KCkge307CgogICAgdmlydHVhbCBUWVBFIEludmFsaWRWYWx1ZSgpIHsgcmV0dXJuIDA7IH07Cgog
cHJpdmF0ZToKfTsKCmludCBtYWluICggaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSApCnsKICAgIENU
eXBlTGlzdDxpbnQ+IGxpc3Q7CgogICAgbGlzdC5SZW1vdmVIZWFkKCk7CgogICAgcmV0dXJuIDA7
Cn0K
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/3662: Incorrect warnings with overridden virtual functions in template class
@ 2001-08-12 8:04 gdr
0 siblings, 0 replies; 2+ messages in thread
From: gdr @ 2001-08-12 8:04 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, gdr, nobody, stuart
Synopsis: Incorrect warnings with overridden virtual functions in template class
Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: gdr
Responsible-Changed-When: Sun Aug 12 08:04:18 2001
Responsible-Changed-Why:
See below.
State-Changed-From-To: open->closed
State-Changed-By: gdr
State-Changed-When: Sun Aug 12 08:04:18 2001
State-Changed-Why:
Well, actually the issue is subtile. In the instantiation
of the base class CList<int>, GCC discovers the declaration of
a virtual function and since every virtual function is used even
if it -appears- unused (a language definition requirement) GCC
proceeds to check semantics restruictions, thus the warning.
Arguably, GCC could use a type-based analysis to discover that
the base class function won't be used and suppress the warning
but I guess that is a feature request.
-- Gaby
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3662&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-08-12 8:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-12 9:16 c++/3662: Incorrect warnings with overridden virtual functions in template class stuart
2001-08-12 8:04 gdr
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).