This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ constructor bug? (and what are the semantics of a RANGE_EXPR?)


Steven Bosscher wrote:
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:

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.

yes, it does look like that. The original termination check was !tree_int_cst_lt (max_index, index); which in normal speak is !(max_index < index) which is index <= max_index so max_index is the inclusive upper bound, at that point (which is what it should be in the RANGE_EXPR).

Where is max_index (in build_zero_init) getting its value in this
case?

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]