[sane-devel] ambiguous post-increment in canon-sane.c

bertrik at sikken.nl bertrik at sikken.nl
Mon Dec 11 13:23:20 CET 2006

> On Dec 8 15:34 Ulrich Deiters wrote (shortened):
>> Interesting! The incriminated C code looked perfectly innocent
>> to me (if the incrementing operation is carried out after all
>> assignments, as it should, there is no ambiguity).
> Perhaps "ambiguous" is not exactly the right word because
> in a textbook about C I read that '++' and '--' are not allowed
> on the left side of '=' (e.g. x++ = 1; is not allowed) and in
> this case the compiler should complain regarding "lvalue".

Your example is not representative:
The original has *p++ as lvalue, not p++, so *p is assigned and not p
(and p is post-incremented).

I've seen a lot of code that does *x++ = *y++ (to copy something)
and I've never seen a compiler complain about that.

I agree that the solution proposed earlier is a bit cleaner (and
probably easier to understand).

Kind regards,

More information about the sane-devel mailing list