C++ PATCH: sizeof(expr)

Mark Mitchell mark@codesourcery.com
Fri Sep 10 11:27:00 GMT 1999


>>>>> "Nathan" == Nathan Sidwell <nathan@acm.org> writes:

    Nathan> Hi, the attached patch fixes the XFAILS in
    Nathan> g++.other/sizeof[34].C that I recently added.

    Nathan> I added a warning, if the expression has side effects --
    Nathan> let me know if you'd prefer that not to be given.  I

I think not.  Richard's right; people put sizeof in macros all over
the place.

    Nathan> couldn't find any justification to the comment about the
    Nathan> invalidity of sizeof(X::i), (modulo accessibility) and

Here's the quote:

[expr.prim]

An id-expression that denotes a nonstatic  data  member  or  nonstatic
  member function of a class can only be used:

  --as  part  of a class member access (_expr.ref_) in which the object-
    expression refers to the member's class or a class derived from that
    class, or

  --to form a pointer to member (_expr.unary.op_), or

  --in  the  body  of  a nonstatic member function of that class or of a
    class derived from that class (_class.mfct.nonstatic_), or

  --in a mem-initializer for a constructor for that class or for a class
    derived from that class (_class.base.init_).

    Nathan> it's not correct about the pedantic flag anyway. If I've
    Nathan> missed something I'll put a reference to the part of the
    Nathan> standard in that comment.

Thanks; a reference to [expr.prim] is in order.  Go ahead and put that
in, for sure.

How do we know that all callers of build_compound_expr will do the
deay that is no longer being done there?  I suppose if you tested it,
that's roughly good enough.  Let's get Jason's thoughts, though.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


More information about the Gcc-patches mailing list