Re: C and side-effects

From: Johan Kullstam (kullstam@ne.mediaone.net)
Date: Wed May 03 2000 - 21:36:34 EST


"John Anthony Kazos Jr." <jkazos@vt.edu> writes:

> Since when do compilers as a rule obey the standard?

what if you write

 x = 3;

and this sets x to 2?

at some point you have to depend on the compiler actually implementing
the language it purports to do. depending upon the && short circuit
isn't obscure -- it's well defined and it's commonly used. all C
compilers get this right or their users complain *loudly*. this is a
basic semantic functionality that many programs depend upon.

> I'm not bashing
> gcc (though I *am* bashing Micro$oft and most others) because gcc's
> problems are due to its nature as open software (i.e., no one's
> paying the developers, so they have to do it when they have
> time). Relying on standards having been followed with an open
> software product is foolish, and doing so with a closed software
> product is inane.

the kernel *requires* gcc. many other things in the kernel code
really are non-standard and depend on gcc extensions. therefore, we
need not concern ourselves with what some hypothetical broken compiler
might do with it.

> >On Wed, 3 May 2000, Cesar Eduardo Barros wrote:
> >
> >> while ((mm->swap_cnt << 2 * (i + 1) < max_cnt) && i++ < 10)
> >> /* nothing */;
> >>
> >> I'm not that good at C, mas aren't expressions with side-effects
> >> ill-defined? How can we be sure (short of tracking the gcc
> >> mailing lists) that i will be incremented after the left part of
> >> the test?
> >
> >Because it is defined in the C standard?
> >
> >Rik
> >--
> >The Internet is not a network of computers. It is a network
> >of people. That is its real strength.
> >
> >Wanna talk about the kernel? irc.openprojects.net / #kernelnewbies
> >http://www.conectiva.com/ http://www.surriel.com/
> >
> >
> >-
> >To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> >the body of a message to majordomo@vger.rutgers.edu
> >Please read the FAQ at http://www.tux.org/lkml/
> >
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/

-- 
J o h a n  K u l l s t a m
[kullstam@ne.mediaone.net]
Don't Fear the Penguin!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:13 EST