[sane-devel] C undefined operations in sane-backends-1.0.7-b

Tim Waugh twaugh at redhat.com
Thu Jan 24 09:15:46 GMT 2002


On Thu, Jan 24, 2002 at 08:49:56AM +0100, Joachim Backes wrote:

> 1. Since 20 years, C is my favorite programming language

C has become defined better in recent years.  Take a read of C99, for
instance.

> 2. Since some years, I give classes in C
> 3. The code line "bit = ++bit % 8", is fully correct.
>    Reason:
>       a) ++ has higher priority than %
>       b) What happens: i) bit will be incremented
>                        ii) the modulo 8 operation is done
>                        iii) the result will be stored in bit

There are two assignments to the same variable with no sequence points
in between, and so the compiler is free to order them any way it feels
is better.  Take a read of C99.

> 4. Meaning of "bit = ++bit"??? The same does "++bit"

Well, only because either order happens to produce the same result.

> 5. None of my C compilers (gcc or IRIX c compiler) report
>    any warning.

GCC doesn't yet, but it will.  Try CVS, for instance (which is what
I'm using).

I don't expect that any compilers you are using issue warnings for (to
take a wild example) spelling mistakes in string literals either!  It
doesn't mean that there are none.

> 7. The compiler which produces the warning is buggy!

You'd better stay away from GCC then, for fear of 'bugs'.

This list is hardly a good forum for this issue though; perhaps
comp.std.c or something would be a better place for you to raise your
concern.

Tim.
*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20020124/3b4bdb72/attachment.sig>


More information about the sane-devel mailing list