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

Tim Waugh twaugh@redhat.com
Thu, 24 Jan 2002 09:15:46 +0000


--RacQGezy2Y99S6cT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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.
*/

--RacQGezy2Y99S6cT
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8T9DCyaXy9qA00+cRArmAAJwOAbib/gm0oT7VZ9yDsiTC3bIsOgCgo/cq
N/1LaZ80CRZf0avoXA2eo6k=
=rEZy
-----END PGP SIGNATURE-----

--RacQGezy2Y99S6cT--