Article View: comp.std.c
Article #203Re: What's EOF when sizeof(int)==sizeof(char)?
From: Blair P. Houghton
Date: Fri, 03 Apr 1992 16:59
Date: Fri, 03 Apr 1992 16:59
50 lines
2596 bytes
2596 bytes
In article <1992Apr02.223752.4101@ima.isc.com> karl@ima.isc.com (Karl Heuer) writes:
>In article <TT.92Mar31175445@tarzan.jyu.fi> tt@tarzan.jyu.fi (Tapani Tarvainen) writes:
>>As far as I can tell the standard allows int to be of the same size as char,
>>as long as it's at least 16 bits. [But what about EOF being out of band?]
EOF is a negative integer that is not otherwise a recognized
character value. It's up to the implementation to ensure
that there's no conflict between EOF and a recognizable
character. As it stands, ^Z or ^D are in most terminal
conventions not `CHAR_MIN - 1', and it is up to the
terminal driver to convert the recognized character into
the proper EOF value for the processes that read the
stream.
There's no requirement for the value of SCHAR_MIN
to be the least value possible in the given bit-width.
If int and char are both 16 bits, it's still possible for
char to be considered `unsigned char', so long as the
`signed int' interpretation of the number allows for a
negative value for EOF.
"Out of band" necessarily requires a definition of "in band."
>This is actually an argument in favor of the viewpoint that X3J11 does *not*
>allow sizeof(int)==sizeof(char). If it hasn't been done already, somebody
>should send in a Request For Interpretation. I hope that the official answer
>is that such implementations are not legal.
What's wrong with it? The implementation (plus platform
and OS) merely need to coordinate their use of the values
of the char type so that there's one that matches EOF and
it means end-of-file.
>I would not expect such a compiler to do well in the marketplace, anyway.
>Having a 16-bit char type means that there's way to access an 8-bit datum.
^no(?)
Of course, all of the character-retrieval functions
actually "access" 8-bit data by returning 16-bit data
and letting the programmer mask for 8 bits...
As for 9-bit char machines, I'd call them rather a
qualified success...
--Blair
"We've got data hiding
and procedure hiding,
now all we need is
policy hiding..."
Technical Details
Message-ID:
<10211@inews.intel.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!iWarp.intel.com|ichips!inews!hopi!bhoughtoReferences:
<TT.92Mar31175445@tarzan.jyu.fi> <1992Apr02.223752.4101@ima.isc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!iWarp.intel.com|ichips!inews!hopi!bhoughto From: bhoughto@hopi.intel.com (Blair P. Houghton) Newsgroups: comp.std.c Subject: Re: What's EOF when sizeof(int)==sizeof(char)? Message-ID: <10211@inews.intel.com> Date: 3 Apr 92 16:59:42 GMT References: <TT.92Mar31175445@tarzan.jyu.fi> <1992Apr02.223752.4101@ima.isc.com> Sender: news@inews.intel.com Organization: Intel Corp, Chandler, AZ Lines: 50