Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Type system protocols rest atop fundamental data Date: Sat, 17 Jun 2017 16:10:36 -0700 Organization: None to speak of Lines: 31 Message-ID: References: <31b443b2-2142-417f-812a-955280ff39d8@googlegroups.com> <1d495f2d-77f2-4a89-b695-ae74df6ea664@googlegroups.com> <87fuf28f8o.fsf@bsb.me.uk> <9Ij0B.155016$m76.119451@fx35.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="1d5a24d016722a50a74735015b7fb40e"; logging-data="5820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nWGPOe7pJyQzcTKedWT0N" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PnRgcUIN2lJNlaFRbz/V7Y7CLts= sha1:3nS5ypAax/Fg4+HGdjVjVNOIJ0E= Xref: csiph.com comp.lang.c:112416 Tim Rentsch writes: > Keith Thompson writes: [...] >> Each enum type is compatible with some integer type. gcc treats Colour >> and Day as compatible with unsigned int, but not with each other (which >> is valid, type compatibility is not necessarily transitive). >> >> My understanding is that Colour and Day are *not* compatible, even >> if they're both compatible with the same integer type, and that >> any conforming compiler must diagnose the assignment. (gcc does >> in conforming mode.) I'm not 100% confident in that conclusion. > > The Standard doesn't say this explicitly, but presumably the > rules in the Standard for type compatibility are meant to be > exhaustive. If that is the case (and IMCO that intended > meaning is much more likely than not), then Colour and Day > cannot be compatible: distinct enumerations are distinct > types, and since nothing else is saying that they /are/ > compatible, they aren't. I believe you're right. I think there's a tendency to assume that type compatibility is transitive; it seems odd (at least to me) for type A to be compatible with types B and C, but B and C not to be compatible with each other. But the standard never says it's a transitive relationship, and it isn't. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"