🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2899

Compatability of enum types and integer types

#2899
From: Ronald F. Guilmette
Date: Mon, 21 Dec 1992 22:56
40 lines
1804 bytes
The ANSI C standard says (in 3.5.2.2):

	"Each enumerated type shall be compatible with an integer type;
	the choice of type is implementation-defined."

I am having a polite disagreement with one implementor regarding the
proper interpretation of this statement.

I interpret it to mean that there *must* exist some integer type `T'
such that:

		enum E { red, green, blue };

		enum E object;
		T object;

		enum E *ptr;
		T *ptr;

... is a valid translation unit.

The person on the other side of this discussion seems to be claiming that
indeed the standard requires the existence of such an integer type, but
that the implementation may "put the fix in" so that no matter what type
you try to use for `T', the implementation will say "Sorry.  You guessed
wrong.  I'm using a different integer type as the `compatible' type for
that particular enum type."

Does this sound like dirty pool or what?

-- 

// Ron ("Loose Cannon") Guilmette    uucp: ...uunet!lupine!segfault!rfg
//
//      "On the one hand I knew that programs could have a compelling
//       and deep logical beauty, on the other hand I was forced to
//       admit that most programs are presented in a way fit for
//       mechanical execution, but even if of any beauty at all,
//       totally unfit for human appreciation."
//                                              -- Edsger W. Dijkstra
Technical Details
Message-ID: <1992Dec21.225604.18749@netcom.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!rfg

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!rfg
From: rfg@netcom.com (Ronald F. Guilmette)
Subject: Compatability of enum types and integer types
Message-ID: <1992Dec21.225604.18749@netcom.com>
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Mon, 21 Dec 1992 22:56:04 GMT
Lines: 40