This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
C++ constructor bug? (and what are the semantics of a RANGE_EXPR?)
- From: Steven Bosscher <stevenb at suse dot de>
- To: gcc at gcc dot gnu dot org, nathan at codesourcery dot com
- Date: Thu, 16 Dec 2004 09:45:18 +0100
- Subject: C++ constructor bug? (and what are the semantics of a RANGE_EXPR?)
- Organization: SUSE Labs
Hi,
With a patch for the wrong-code bug PR18191 I'm seeing a new failure
for g++.dg/init/new4.C. That test case looks like this:
int *x = new int [2] ();
which looks like this in the .original tree dump:
(void) (x = (int *) (TARGET_EXPR <D.1910, (int[2] *) operator new [] (8)>, try
{
*D.1910 = {0};
}
catch
{
operator delete [] ((void *) D.1910);
}, D.1910))
When I count the number of elements in the constructor for this test,
I get 3 elements. The tree looks like this:
<constructor 0x2a95999c00
type <array_type 0x2a959e1b60
type <integer_type 0x2a958979a0 int public SI
size <integer_cst 0x2a95890a20 constant invariant 32>
unit size <integer_cst 0x2a95890540 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0x2a95890990 -2147483648> max <integer_cst 0x2a958909c0 2147483647>
pointer_to_this <pointer_type 0x2a958b3c40>>
BLK
size <integer_cst 0x2a95890bd0 constant invariant 64>
unit size <integer_cst 0x2a95890c00 constant invariant 8>
align 32 symtab 0 alias set -1
domain <integer_type 0x2a9596a540 type <integer_type 0x2a95897380 long unsigned int>
DI size <integer_cst 0x2a95890bd0 64> unit size <integer_cst 0x2a95890c00 8>
align 64 symtab 0 alias set -1 precision 64 min <integer_cst 0x2a95890570 0> max <integer_cst 0x2a95890660 1>>
pointer_to_this <pointer_type 0x2a959e1ee0>>
constant invariant
arg 0 <tree_list 0x2a9599bf00
purpose <range_expr 0x2a958968c0 type <integer_type 0x2a95897380 long unsigned int>
constant invariant
arg 0 <integer_cst 0x2a95890570 constant invariant 0>
arg 1 <integer_cst 0x2a95890870 constant invariant 2>>
value <integer_cst 0x2a958ac690 constant invariant 0>>>
Note especially the last two lines. There is a RANGE_EXPR with two
operands, with values 0 and 2. This comes out of the C++ front end
and I suspect it's wrong. From the comment for CONSTRUCTOR:
If the TREE_PURPOSE is a RANGE_EXPR, it is a short-hand for many nodes,
one for each index in the range.
But the index "2" is not in the range for the target object of this
constructor. Smells like off-by-one in the C++ front end.
But I can't be sure because RANGE_EXPR is not documented. Not in
doc/c-tree.texi and not in tree.def (ARRAY_RANGE_REF is also not in
the texi file btw).
Help! anyone? :-)
Gr.
Steven