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: skip_evaluation



In asking this, I'm particularly puzzled by code like this in
build_base_path in cp/class.c:

  /* Don't bother with the calculations inside sizeof; they'll ICE if the
     source type is incomplete and the pointer value doesn't matter.  */
  if (skip_evaluation)
    {
      expr = build_nop (build_pointer_type (target_type), expr);
      if (!want_pointer)
	expr = build_indirect_ref (EXPR_LOCATION (expr), expr, NULL);
      return expr;
    }

Presumably the early return is OK within a sizeof expression; it is OK
within an expression like (0 ? x : y)?

From reading the code, I'd say yes. The bug that Jason fixed is related to stuff that cannot appear within a constant expression except within sizeof -- for example


   struct B {};
   struct D : public B {
       static const int i = sizeof((B*)(D*)0);
   };

   struct Z {};
   struct A : Z {};
   Z* implicitToZ (Z*);
   struct B : A {
       static const int i = sizeof(implicitToZ((B*)0));
   };

   struct B {};
   struct D;
   D* p;
   struct D: public B {
       static const int i = sizeof ((B*)p);
   };

(see PR27177). All of these would still be forbidden within (0?x:y).

Paolo


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