Jason,
I'm trying to triage an ICE that we found in one of our internal builds 
on a recent merge from trunk.  The ICE occurs in:
static tree
cxx_eval_indirect_ref (const constexpr_call *call, tree t,
                       bool allow_non_constant, bool addr,
                       bool *non_constant_p)
{
[ ... ]
  if (r)
    r = cxx_eval_constant_expression (call, r, allow_non_constant,
                                      addr, non_constant_p);
  else
    {
      tree sub = op0;
      STRIP_NOPS (sub);
      if (TREE_CODE (sub) == ADDR_EXPR
          || TREE_CODE (sub) == POINTER_PLUS_EXPR)
        {
==>          gcc_assert (!same_type_ignoring_top_level_qualifiers_p
==>                      (TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t)));
          /* DR 1188 says we don't have to deal with this.  */
          if (!allow_non_constant)

at the point of the failure, we have:

t: *((const uint8 *) &XX[0] + 1);
sub: (const uint8 *) &XX[0] + 1;

and (naturally) TREE_TYPE(t) is the same as TREE_TYPE(TREE_TYPE(sub)), so the assertion fails trivially.
AFAICT, this assertion was introduced by

commit ace3c39fedeb99434010407708a44e397c45b535
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Nov 2 01:31:02 2010 +0000

        * semantics.c (constexpr_call): New datatype.
        (constexpr_call_table): New global table.
        (constexpr_call_hash): New.
        (constexpr_call_equal): Likewise.
        (maybe_initialize_constexpr_call_table): Likewise.
        (lookup_parameter_binding): Likewise.
        (cxx_eval_builtin_function_call): Likewise.
        (cxx_bind_parameters_in_call): Likewise.
        (cxx_eval_call_expression): Likewise.
        (cxx_eval_unary_expression): Likewise.
        (cxx_eval_binary_expression): Likewise.
        (cxx_eval_conditional_expression): Likewise.
        (cxx_eval_array_reference): Likewise.
        (cxx_eval_component_reference): Likewise.
        (cxx_eval_logical_expression): Likewise.
        (cxx_eval_object_construction): Likewise.
        (cxx_eval_constant_expression): Likewise.
        (cxx_eval_indirect_ref): Likewise.
        (cxx_constant_value): Likewise.
        (cxx_eval_bare_aggregate): Likewise.
        (adjust_temp_type): New.
        (reduced_constant_expression_p): New.
        (verify_constant): New.
        (cxx_eval_vec_init, cxx_eval_vec_init_1): New.
        (cxx_eval_outermost_constant_expr): New.
        (maybe_constant_value, maybe_constant_init): New.
        (cxx_eval_constant_expression): Use them.
        * cp-tree.h: Declare fns.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166166 138bc75d-0d04-0410-961f-82ee72b054a4
and later patched up in its present form by:

commit 97bf331110778169510a07a3ba8a42778c2826ce
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jun 14 18:15:43 2011 +0000

        PR c++/49290
        * semantics.c (cxx_fold_indirect_ref): Local, more permissive copy
        of fold_indirect_ref_1.
        (cxx_eval_indirect_ref): Use it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175041 138bc75d-0d04-0410-961f-82ee72b054a4
The values for T and SUB seem to come unmodified all the way up from 
process_init_constructor_array.  The original source code where this is 
coming from is:
const uint8 F::V[] = {
  ...
  *(reinterpret_cast<const uint8*>(&XX[0]) + 1),
  ...
};

I cannot tell whether the code is wrong or the compiler. We do not seem to making any transformations. Could this be an unrelated change in the parser?
This code seems to be enabled only with -Wall, the following reproducer 
only fails if compiled with -Wall:
$ cat a.cc
typedef unsigned char uint8;
typedef unsigned int uint32;

const uint32 XX[] = { 1, 3, 7 };

const uint8 V[] = {
  *(reinterpret_cast<const uint8*>(&XX[0]) + 0),
  *(reinterpret_cast<const uint8*>(&XX[0]) + 1),
  *(reinterpret_cast<const uint8*>(&XX[0]) + 2),
  *(reinterpret_cast<const uint8*>(&XX[0]) + 3),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 0),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 1),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 2),
  *(reinterpret_cast<const uint8*>(&XX[1]) + 3),
};

$ g++ -Wall -c a.cc
a.cc:15:1: internal compiler error: in cxx_eval_indirect_ref, at cp/semantics.c:7321
Please submit a full bug report,
with preprocessed source if appropriate.

Is there anything that rings a bell here, or would you prefer me to file a PR?

Thanks.  Diego.

Reply via email to