This is the mail archive of the 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]

[C++ PATCH] Fix ICE on new with value dependent args (PR c++/34336)


When building new with processing_template_decl, where neither args, placement
nor type are type dependent, but something is value dependent, build_new
might create NON_DEPENDENT_EXPRs:
  if (processing_template_decl)
      if (dependent_type_p (type)
          || any_type_dependent_arguments_p (placement)
          || (nelts && type_dependent_expression_p (nelts))
          || (init != void_zero_node
              && any_type_dependent_arguments_p (init)))
        return build_raw_new_expr (placement, type, nelts, init,
      placement = build_non_dependent_args (placement);
      if (nelts)
        nelts = build_non_dependent_expr (nelts);
      if (init != void_zero_node)
        init = build_non_dependent_args (init);
and call build_new_1 with that.  But stabilize_expr doesn't really like
to be called with NON_DEPENDENT_EXPR with side effects, e.g. get_target_expr
on it won't return a TARGET_EXPR, and there is really no point in
stabilizing expressions in templates, all we care about is issue proper
diagnostic and then throw everything away and just build_raw_new_expr
from the original arguments. 

Attached are 2 possible approaches, one modifies stabilize_call and
stabilize_init to return immediately if processing_template_decl
(similarly e.g. to how cp_save_expr returns immediately), the other
modifies the caller (build_new_1) not to call these when
processing_template_decl.  stabilize_call is only called by stabilize_init
and build_new_1, stabilize_init is only called by build_new_1 and
build_throw (but the later only if !processing_template_decl).
So both patches are functionally equivalent.  I've regtested both with
make check-g++ and will throw the first one in the bootstrap/full regtest
I'm about to start.

Ok for trunk?  Which one?


Attachment: Z86
Description: Text document

Attachment: Z86a
Description: Text document

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