[comp.std.c] Can an enumerator be assigned to an int?

karl@haddock.ima.isc.com (Karl Heuer) (05/26/90)

In article <1421@sdrc.UUCP> gcglan@sdrc.UUCP (Frank Glandorf) writes:
>	a=CIRCLE;
>%CC-W-ENUMCLASH, Mismatched enum type in "=" operation.
     ^
I presume from this codeletter that the implementation did not in fact
terminate the compilation as a result of the mismatch.

>I think this should be ok because according to section 3.5.2.2...
>"The identifiers in an  enumerator list are delcared as
>constants that have type int and may appear  wherever such are
>permitted." 

2.1.1.3 footnote 6: "Of course, an implementation is free to produce any
number of [warning] diagnostics".  A.5 common warnings: "A value is given to
an object of enumeration type other than by assignment of [something of the
same enumeration type]."

In diagnosing violations of the strong-enum model, the implementation is
(a) legally in the right (as long as it is only a warning) and also (b)
morally in the right (as long as there is an option to disable the warning).

Clause (a) is a fact.  (b) is my opinion, and I stand by it even though the
example in A.5 involves a copy in the direction opposite that of the posted
code fragment.

Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint

scjones@sdrc.UUCP (Larry Jones) (05/27/90)

In article <16728@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes:
> In article <1421@sdrc.UUCP> gcglan@sdrc.UUCP (Frank Glandorf) writes:
> >	a=CIRCLE;
> >%CC-W-ENUMCLASH, Mismatched enum type in "=" operation.
>      ^
> I presume from this codeletter that the implementation did not in fact
> terminate the compilation as a result of the mismatch.
> 
> 2.1.1.3 footnote 6: "Of course, an implementation is free to produce any
> number of [warning] diagnostics".  A.5 common warnings: "A value is given to
> an object of enumeration type other than by assignment of [something of the
> same enumeration type]."
> 
> In diagnosing violations of the strong-enum model, the implementation is
> (a) legally in the right (as long as it is only a warning) and also (b)
> morally in the right (as long as there is an option to disable the warning).

You're right about (a) and I agree with you about (b) in
priciple, but I have to disagree in this specific case because of
the nature of warnings in Vax C.  The fact that a warning was
issued is recorded in the object file and reiterated every time
you do anything with it like put it in a library or link to it.
Vax C has another category of messages (informational) which are
displayed, but not recorded in the object file which would be
more appropriate for this kind of message.
----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones@SDRC.UU.NET
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
"You know how Einstein got bad grades as a kid?  Well MINE are even WORSE!"
-Calvin