public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available
@ 2003-07-04 9:26 gcc-bugzilla at gcc dot gnu dot org
2003-07-04 21:47 ` [Bug c++/11431] " bangerth at dealii dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2003-07-04 9:26 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11431
Summary: static_cast behavior with subclasses when default
constructor available
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nicolas dot burrus at lrde dot epita dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
Considering the following code:
template <class T> struct static_abort {};
template <class E>
struct any
{
const E& self() const { return static_cast<const E&>(*this); }
};
struct range : public any<range>
{
range() {}
template <class U>
range(const U&)
{
typedef typename static_abort<U>::ret t;
}
};
int main()
{
const any<range>& r = *new range();
r.self();
}
To convert any<range> into range, g++-3.3.1 tries to use the generic
constructor of range instead of using the subclass relationship
between them. Even if I could not find in the C++ standard a priority
rule for this particular case, previous versions of g++ (up to 3.3),
Intel c++ compiler, and Comeau c++ compiler choose the subclassing
conversion when possible.
Environment:
System: Linux ouagadougou 2.4.20 #1 Tue Jun 10 07:33:08 CEST 2003 i686 GNU/Linux
Architecture: i686
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i386-linux
How-To-Repeat:
Compile the given code.
------- Additional Comments From nicolas dot burrus at lrde dot epita dot fr 2003-07-04 09:26 -------
Fix:
Use reinterpret_cast instead of static_cast.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/11431] static_cast behavior with subclasses when default constructor available
2003-07-04 9:26 [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available gcc-bugzilla at gcc dot gnu dot org
@ 2003-07-04 21:47 ` bangerth at dealii dot org
2003-07-05 19:36 ` mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2003-07-04 21:47 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11431
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Priority|P3 |P1
Last reconfirmed|0000-00-00 00:00:00 |2003-07-04 21:47:50
date| |
Target Milestone|--- |3.3.1
------- Additional Comments From bangerth at dealii dot org 2003-07-04 21:47 -------
Confirmed. This is a regression on 3.3 and 3.4, with behavior in the
branch changing somewhen after 6-22 and before now.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/11431] static_cast behavior with subclasses when default constructor available
2003-07-04 9:26 [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available gcc-bugzilla at gcc dot gnu dot org
2003-07-04 21:47 ` [Bug c++/11431] " bangerth at dealii dot org
@ 2003-07-05 19:36 ` mmitchel at gcc dot gnu dot org
2003-07-06 3:31 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-07-05 19:36 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11431
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mmitchel at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/11431] static_cast behavior with subclasses when default constructor available
2003-07-04 9:26 [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available gcc-bugzilla at gcc dot gnu dot org
2003-07-04 21:47 ` [Bug c++/11431] " bangerth at dealii dot org
2003-07-05 19:36 ` mmitchel at gcc dot gnu dot org
@ 2003-07-06 3:31 ` cvs-commit at gcc dot gnu dot org
2003-07-06 3:41 ` cvs-commit at gcc dot gnu dot org
2003-07-06 3:47 ` mmitchel at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-07-06 3:31 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11431
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-07-06 03:31 -------
Subject: Bug 11431
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: mmitchel@gcc.gnu.org 2003-07-06 03:30:57
Modified files:
gcc/cp : ChangeLog call.c cp-tree.h cvt.c decl.c init.c
semantics.c typeck.c typeck2.c
gcc/testsuite : ChangeLog
gcc/testsuite/g++.old-deja/g++.jason: typeid1.C
Added files:
gcc/testsuite/g++.dg/expr: static_cast3.C
Log message:
PR c++/11431
* typeck.c (build_static_cast): Check for reference conversions
earlier.
* cp-tree.h (perform_integral_promotions): Declare.
* call.c (build_addr_func): Use decay_conversion.
(convert_arg_to_ellipsis): Likewise. Remove misleading comment.
(convert_for_arg_passing): Use perform_integral_promotions.
* cvt.c (build_expr_type_conversion): Use decay_conversion.
(type_promotes_to): Do not return a cv-qualified type.
* decl.c (grok_reference_init): Fix formatting.
(get_atexit_node): Use decay_conversion.
(build_enumerator): Use perform_integral_promotions.
* init.c (build_vec_init): Use decay_conversion.
* semantics.c (finish_expr_stmt): Likewise.
(finish_switch_cond): Use perform_integral_promotions.
* typeck.c (default_conversion): Likewise.
(perform_integral_promotions): New function.
(build_indirect_ref): Use decay_conversion.
(build_array_ref): Use perform_integral_promotions.
(convert_arguments): Use decay_conversion.
(build_unary_op): Use perform_integral_promotions.
(build_c_cast): Use decay_conversion.
(build_modify_expr): Likewise.
(convert_for_initialization): Likewise.
* typeck2.c (build_x_arrow): Likewise.
* g++.old-deja/g++.jason/typeid1.C: Make it a compile test, not a
run test.
PR c++/11431
* g++.dg/expr/static_cast3.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3490&r2=1.3491
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.400&r2=1.401
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.867&r2=1.868
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cvt.c.diff?cvsroot=gcc&r1=1.140&r2=1.141
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1079&r2=1.1080
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.327&r2=1.328
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.319&r2=1.320
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.472&r2=1.473
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&r1=1.142&r2=1.143
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2844&r2=1.2845
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/expr/static_cast3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C.diff?cvsroot=gcc&r1=1.7&r2=1.8
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/11431] static_cast behavior with subclasses when default constructor available
2003-07-04 9:26 [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available gcc-bugzilla at gcc dot gnu dot org
` (2 preceding siblings ...)
2003-07-06 3:31 ` cvs-commit at gcc dot gnu dot org
@ 2003-07-06 3:41 ` cvs-commit at gcc dot gnu dot org
2003-07-06 3:47 ` mmitchel at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-07-06 3:41 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11431
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-07-06 03:41 -------
Subject: Bug 11431
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_3-branch
Changes by: mmitchel@gcc.gnu.org 2003-07-06 03:41:29
Modified files:
gcc/cp : ChangeLog typeck.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/expr: static_cast3.C
Log message:
PR c++/11431
* typeck.c (build_static_cast): Check for reference conversions
earlier.
PR c++/11431
* g++.dg/expr/static_cast3.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.174&r2=1.3076.2.175
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.436.2.10&r2=1.436.2.11
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.217&r2=1.2261.2.218
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/expr/static_cast3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/11431] static_cast behavior with subclasses when default constructor available
2003-07-04 9:26 [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available gcc-bugzilla at gcc dot gnu dot org
` (3 preceding siblings ...)
2003-07-06 3:41 ` cvs-commit at gcc dot gnu dot org
@ 2003-07-06 3:47 ` mmitchel at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-07-06 3:47 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11431
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
------- Additional Comments From mmitchel at gcc dot gnu dot org 2003-07-06 03:47 -------
Fixed in GCC 3.3.1 and GCC 3.4.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-07-06 3:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-04 9:26 [Bug c++/11431] New: static_cast behavior with subclasses when default constructor available gcc-bugzilla at gcc dot gnu dot org
2003-07-04 21:47 ` [Bug c++/11431] " bangerth at dealii dot org
2003-07-05 19:36 ` mmitchel at gcc dot gnu dot org
2003-07-06 3:31 ` cvs-commit at gcc dot gnu dot org
2003-07-06 3:41 ` cvs-commit at gcc dot gnu dot org
2003-07-06 3:47 ` mmitchel 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).