Path: utzoo!mnetor!uunet!husc6!mailrus!tut.cis.ohio-state.edu!osu-cis!att-cb!att-ih!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: typedef laxity Message-ID: <4310@ihlpf.ATT.COM> Date: 7 Apr 88 00:58:09 GMT References: <1070@maynard.BSW.COM> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 40 Keywords: typedef lint In article <1070@maynard.BSW.COM> campbell@maynard.BSW.COM (Larry Campbell) writes: >It seems to me someone should complain about this code: > > typedef int TEMPERATURE; > typedef int PRESSURE; > > TEMPERATURE tx, ty; > PRESSURE px, py; > > ty = py; /* type clash */ > >But none of the compilers I've tested (pcc, VAX-11 C, Wang VS C, Turbo C) >complain about it, and, even worse, _lint_ doesn't complain! Someone IS complaining about this code: you! Remember, this is C, not Pascal :-)! This is perfectly legitimate C code, since: "typedef does not introduce brand new types, only synonyms for types which could be specified in another way." (K&R 1, C Reference Manual, section 8.8. Almost the same wording appears in section 3.5.6 of dpANS). Since this is perfectly legal, I don't want my compiler to complain about it. >Does anyone know of a lint or compiler that will complain about it? >Does anyone disagree that lint's silence in this case is a bug? >(Especially since lint does complain about mixing enum types...) I'm not sure how you could mix enum types within C's scoping rules, so this should always be flagged as an *error* (correct me via email if I'm wrong about this, though). Now, if you want lint to issue a warning about mixing typedefs, it's fine by me (since I don't use them very often). But please make sure that a flag to lint is provided to turn these warnings off. -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_