side effects inside sizeof

ShanklandJA opus at drutx.UUCP
Tue May 15 23:25:07 AEST 1984


Joey Duhon (ihuxj!duhon) writes:

    On page 126 we read "The expression sizeof(object) yields an
    integer equal to the size of the specified object. ... The object can be
    an acutual variable or array or structure, ..."
    I don't see anything here about other expressions.
    The confusion seems to be over the reference manual which indicates
    that the grammar will accept "sizeof expression" syntactically.
    This is obviously a shortcut for the compiler writer(s).
    However, the semantic interpretation is explained above(p.126).

    This all seems clear to me.

Good point, but we've still got a compiler problem here, I'd say.
If sizeof( x++ ) is really a semantic error, then the compiler ought
to be complaining about it, rather than quietly doing its own thing,
whatever that may be.  Undeclared variables are also permitted by
the C syntax -- that is, they are a semantic error -- but I imagine
howls would be heard far and wide (mine certainly would be) if a C
compiler issued no error message for an undeclared variable, and issued
code that dumped core the first time that variable was referenced or
assigned to.

Jim Shankland
..!ihnp4!druxy!opus



More information about the Comp.lang.c mailing list