This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
- From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jan 2006 18:49:07 -0000
- Subject: [Bug c++/25895] [4.0/4.1/4.2 Regression] wrong code with ?: and derived class pointers
- References: <bug-25895-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from mmitchel at gcc dot gnu dot org 2006-01-21 18:49 -------
This regression comes from the changes that were made (by Jason, I believe) to
use base class FIELD_DECLs to perform casts from derived to base classes,
rather than just pointer arithmetic.
In build_base_path, we decide not to generate an explicit test for NULL because
we've noticed that the base class is at offset zero relative to the derived
class, and therefore we know that the conversion will be a no-op. As an
optimization, we avoid generating the NULL test.
We end up with:
ADDR_EXPR (COMPONENT_REF (INDIRECT_REF 0) (FIELD_DECL base))
which c_common_truthvalue_conversions "knows" must be non-NULL.
I believe that in the case that we know that the conversion is a no-op, we
should just return a NOP_EXPR, rather than going through the fields.
This is a P1.
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Priority|P3 |P1
Last reconfirmed|0000-00-00 00:00:00 |2006-01-21 18:49:07
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25895