🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3107

Re: Non-Portable pointer assignment?

#3107
From: Norman Diamond
Date: Fri, 07 Jun 1991 01:36
32 lines
2454 bytes
In article <MCDANIEL.91Jun6111329@dolphin.adi.com> mcdaniel@adi.com (Tim McDaniel) writes:

>So why in creation was 'x' ever specified to be int?  Why not char,
>with the usual widening in expressions?

The answer is very ugly.  Some old programs took advantage of being able
to put more than one char in a char constant, since it was really an int.
Anyway, no one ever thought of asking "sizeof" of a char constant because
"sizeof" of a char was always 1 anyway, and no one multiplied by something
they knew was 1.  And outside of "sizeof", you can't distinguish one kind
of integer constant from another.  For example, there's no way of specifying
a short constant.  (Well, you can specify a long, but that's because ints
didn't automatically promote to longs.  And you can now specify unsigned,
but this didn't break any existing code, I think.)

>And why did X3J11 specify that the types of enum constants were int,
>rather than the same type as the underlying enum type?

Actually this is one of the few consistent things around.  For example,
3 is not a char even though it fits in one, and 3 is not a short even
though it fits in one.

If you really want to be horrified, I cannot find any requirement that
an enumeration type actually be able to hold all of the values of its
members.  For example, in
  enum what_type { a = -1, b = 1000000 } what;
well enum what_type might be compatible with unsigned short, and what
might be unable to hold the value of a or b....
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
Technical Details
Message-ID: <1991Jun7.013605.728@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond
References: <mccX31w164w@cybrspc> <JXey32w164w@dat1hb.north.de> <1991Jun5.085138.21366@prl.dec.com> <1991Jun5.150527.22942@klaava.Helsinki.FI> <MCDANIEL.91Jun6111329@dolphin.adi.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond
From: diamond@jit533.swstokyo.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Non-Portable pointer assignment?
Message-ID: <1991Jun7.013605.728@tkou02.enet.dec.com>
Date: 7 Jun 91 01:36:05 GMT
References: <mccX31w164w@cybrspc> <JXey32w164w@dat1hb.north.de> <1991Jun5.085138.21366@prl.dec.com> <1991Jun5.150527.22942@klaava.Helsinki.FI> <MCDANIEL.91Jun6111329@dolphin.adi.com>
Sender: usenet@tkou02.enet.dec.com (USENET News System)
Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 32