public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24386] New: 4.1: wrong virtual function called in template member
@ 2005-10-15 17:43 gcc-bugzilla at gcc dot gnu dot org
2005-10-15 17:47 ` [Bug c++/24386] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2005-10-15 17:43 UTC (permalink / raw)
To: gcc-bugs
The cvs head of g++ 4.1 miscompiles the following program:
--------------------------------------------------------
extern "C" int printf(...);
struct A
{
virtual void foo () { printf ("A::foo\n"); }
};
struct B : public A
{
virtual void foo () { printf ("B::foo\n"); }
};
template <class T>
void f(T a)
{
((A*)a)->A::foo();
}
int main()
{
f(new B);
return 0;
}
--------------------------------------------------------
I expect this program to print `A::foo'. But instead, it prints:
$ g++ -o x x.cc
$ ./x
B::foo
$
This worked correctly as of the cvs version from a couple weeks ago.
It also works correctly if f() is made into a non-template function.
Here is the dump of f() from the 02.original tree dump, just to verify
that the problem is upstream of here:
;; Function void f(T) [with T = B*] (_Z1fIP1BEvT_)
;; enabled by -tree-original
<<cleanup_point <<< Unknown tree: expr_stmt
OBJ_TYPE_REF(*NON_LVALUE_EXPR <(&a->D.1746)->_vptr.A>;&a->D.1746->0)
(&a->D.1746) >>>
>>;
It's doing a virtual function call, rather than calling A::foo directly.
The problem seems to have been introduced by this change:
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/21592
* pt.c (build_non_dependent_expr): Don't wrap a COMPONENT_REF
with already looked up member functions. Assert we're not
returning a NON_DEPENDENT_EXPR with unknown type.
* typeck.c (finish_class_member_access_expr): We can get
non-template-id-expr baselinks. If the lookup finds a baselink,
remember it even inside templates.
If i revert this change, then the test case is compiled correctly.
Environment:
System: Linux karma 2.6.12.1sss #2 Thu Jul 7 00:28:21 EDT 2005 i686 i686 i386
GNU/Linux
Architecture: i686
<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/sss/gcc/gcc/configure --prefix=/usr/local/gcc
--enable-threads=posix --enable-long-long --enable-languages=c,c++,f95
How-To-Repeat:
See above.
--
Summary: 4.1: wrong virtual function called in template member
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: snyder at fnal dot gov
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/24386] [4.0/4.1 regression] wrong virtual function called in template member
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
@ 2005-10-15 17:47 ` pinskia at gcc dot gnu dot org
2005-10-16 21:49 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-15 17:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-10-15 17:47 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nathan at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|i686-pc-linux-gnu |
GCC host triplet|i686-pc-linux-gnu |
GCC target triplet|i686-pc-linux-gnu |
Keywords| |wrong-code
Known to fail| |4.0.3 4.1.0
Known to work| |3.3.3 4.0.0 4.0.2
Last reconfirmed|0000-00-00 00:00:00 |2005-10-15 17:47:15
date| |
Summary|4.1: wrong virtual function |[4.0/4.1 regression] wrong
|called in template member |virtual function called in
| |template member
Target Milestone|--- |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/24386] [4.0/4.1 regression] wrong virtual function called in template member
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
2005-10-15 17:47 ` [Bug c++/24386] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
@ 2005-10-16 21:49 ` pinskia at gcc dot gnu dot org
2005-10-17 12:54 ` nathan at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-16 21:49 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/24386] [4.0/4.1 regression] wrong virtual function called in template member
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
2005-10-15 17:47 ` [Bug c++/24386] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
2005-10-16 21:49 ` pinskia at gcc dot gnu dot org
@ 2005-10-17 12:54 ` nathan at gcc dot gnu dot org
2005-10-17 17:25 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-10-17 12:54 UTC (permalink / raw)
To: gcc-bugs
--
nathan at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |nathan at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-10-15 17:47:15 |2005-10-17 12:54:51
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/24386] [4.0/4.1 regression] wrong virtual function called in template member
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-10-17 12:54 ` nathan at gcc dot gnu dot org
@ 2005-10-17 17:25 ` cvs-commit at gcc dot gnu dot org
2005-10-17 17:29 ` nathan at gcc dot gnu dot org
2005-10-17 17:32 ` cvs-commit at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-17 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from cvs-commit at gcc dot gnu dot org 2005-10-17 17:25 -------
Subject: Bug 24386
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: nathan@gcc.gnu.org 2005-10-17 17:25:19
Modified files:
gcc/cp : ChangeLog cp-tree.h pt.c typeck.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/template: overload7.C
Log message:
cp:
PR c++/24386
* cp-tree.h (BASELINK_QUALIFIED_P): New.
* pt.c (tsubst_copy_and_build): <CALL_EXPR case>: Use it.
* typeck.c (finish_class_member_access_expr): Set it.
testsuite:
PR c++/24386
* g++.dg/template/overload7.C: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4941&r2=1.4942
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1167&r2=1.1168
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1049&r2=1.1050
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.658&r2=1.659
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6204&r2=1.6205
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/overload7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/24386] [4.0/4.1 regression] wrong virtual function called in template member
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-10-17 17:25 ` cvs-commit at gcc dot gnu dot org
@ 2005-10-17 17:29 ` nathan at gcc dot gnu dot org
2005-10-17 17:32 ` cvs-commit at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-10-17 17:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from nathan at gcc dot gnu dot org 2005-10-17 17:29 -------
2005-10-17 Nathan Sidwell <nathan@codesourcery.com>
PR c++/24386
* cp-tree.h (BASELINK_QUALIFIED_P): New.
* pt.c (tsubst_copy_and_build): <CALL_EXPR case>: Use it.
* typeck.c (finish_class_member_access_expr): Set it.
--
nathan at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/24386] [4.0/4.1 regression] wrong virtual function called in template member
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-10-17 17:29 ` nathan at gcc dot gnu dot org
@ 2005-10-17 17:32 ` cvs-commit at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-17 17:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from cvs-commit at gcc dot gnu dot org 2005-10-17 17:32 -------
Subject: Bug 24386
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: nathan@gcc.gnu.org 2005-10-17 17:32:07
Modified files:
gcc/cp : ChangeLog cp-tree.h pt.c typeck.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/template: overload7.C
Log message:
cp:
PR c++/24386
* cp-tree.h (BASELINK_QUALIFIED_P): New.
* pt.c (tsubst_copy_and_build): <CALL_EXPR case>: Use it.
* typeck.c (finish_class_member_access_expr): Set it.
testsuite:
PR c++/24386
* g++.dg/template/overload7.C: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.139&r2=1.4648.2.140
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.16&r2=1.1106.2.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.33&r2=1.978.2.34
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.616.2.21&r2=1.616.2.22
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.463&r2=1.5084.2.464
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/overload7.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24386
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-10-17 17:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-15 17:43 [Bug c++/24386] New: 4.1: wrong virtual function called in template member gcc-bugzilla at gcc dot gnu dot org
2005-10-15 17:47 ` [Bug c++/24386] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
2005-10-16 21:49 ` pinskia at gcc dot gnu dot org
2005-10-17 12:54 ` nathan at gcc dot gnu dot org
2005-10-17 17:25 ` cvs-commit at gcc dot gnu dot org
2005-10-17 17:29 ` nathan at gcc dot gnu dot org
2005-10-17 17:32 ` cvs-commit at gcc dot gnu dot org
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).