Re: Legality of a++ = 1 ?
"Russell Shaw" <rjshawN_o@s_pam.netspace.net.au> wrote in message
>>>>> [ Legality of a++ = 1 ]
> I am writing a C compiler and it can be hard to pinpoint answers in the
> C99 standard. 6.5.2, 6.5.3, and its footnotes looks like a relevent answer
> to disallowing a reliable sequence of operations for a++ = b.
Then it depends on whether A++ can be an lvalue. The 'A' part will be
(otherwise you wouldn't be able to use ++ on it). But it's lvalue-ness is
already expended on '++'; Can you re-use this value on the result of the
whole 'A++' term?
If you can, then you will also be able to do &(A++), and A++ ++ ++, and all
sorts of weird stuff. But some of this, including A++=B would be changing a
variable twice between sequence points (which is a big no-no in C).
Apart from which, no-one looking at A++=B would have a clue what it's
supposed to mean. So if mainstream compilers won't accept it, then I would
just forget about it.
> Half the effort is in figuring out whether something that is technically
> doable is politically allowed by the standard.
It is very tempting when writing compilers to improve on the language,
especially it is trivial to do so. But any sorts of extensions to C are
usually frowned upon, unless ratified by a committee. Or you can just
forget the Standard...