Michael Press
3/19/2011 6:30:00 PM
In article <ln1v23gbbw.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
> Michael Press <rubrum@pacbell.net> writes:
> > int main(void)
> > {
> > ---3;
> > return 0;
> > }
> >
> > error: invalid lvalue in decrement
> >
> > ???
> > Why does this have to be an error?
> > The value could be -4 or -3 or -2.
> > If somebody [shuffles feet] wants
> > to use this construction, then who
> > would stop him?
>
> Apart from the fact that "---3;" is a constraint violation, and
> that every conforming compiler must issue a diagnostic for it, and
> in practice I suspect that every existing compiler will reject it:
>
> Whatever you intended "---3" to mean, there is certainly a
> clearer way to express that meaning. For the most nearly sensible
> interpretation, just write either "-3 - 1" or "-4". Or, since
> you're discarding the result, just delete that line of code.
First, I am brain dead for writing ---3,
and acting as if 3 can be decremented.
Second, it can be parsed as (-(-(-(3)))),
but is not.
Third
int main(void)
{
int x = 3;
---x;
return 0;
}
gets the same error.
In function 'main':
error: invalid lvalue in decrement
A warning is well deserved.
---x can be parsed into
something meaningful in C.
--
Michael Press