Re: What's wrong ?
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Fri, 07 Mar 2008 23:08:58 +0000
santosh said:
CBFalconer wrote:
<snip>
Your book is obsolete and wrong.
The example probably came from K&R2. So you are saying it's obsolete
and wrong. On what basis?
The example is indeed from K&R2 (top of page 18, in fact). K&R2 is neither
obsolete nor wrong.
<snip>
As I explained above, one of the error fouls C89 thru C95,
No, it doesn't. The behaviour of the program under C89 through C95 is
well-defined. The *termination status* is undefined, but that isn't an
error.
the
other fouls on C99.
....for which everyone and his cat has a conforming compiler, of course. I
Don't Think So.
So his compiler is accepting erroneous code -
No, his compiler is accepting correct code. I consider Chuck's amendments
to improve the style of the code, but the code as written works just fine.
no need to encourage it. Of course I didn't think of the simple
solution of the OP not knowing how to signal EOF. But that is
another subject. The code is still WRONG.
The program isn't in error for C90. It merely returns an unspecified
status value. I don't think that invokes undefined behaviour.
Well, it's an undefined termination status, but that's all. The program
does not rely on any unspecified, undefined, or implementation-defined
behaviour (unless you count the possibility of overflowing a long int,
which would take quite a while to achieve), so it can be argued that it is
strictly conforming.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.
- References:
- What's wrong ?
- From: Daniel.C
- Re: What's wrong ?
- From: CBFalconer
- Re: What's wrong ?
- From: santosh
- Re: What's wrong ?
- From: CBFalconer
- Re: What's wrong ?
- From: santosh
- What's wrong ?
- Prev by Date: Backtick, at-sign, dollar-sign: legal in source?
- Next by Date: Re: Tell me about makefiles
- Previous by thread: Re: What's wrong ?
- Next by thread: Re: What's wrong ?
- Index(es):
Relevant Pages
|