Path: utzoo!mnetor!uunet!mcvax!ukc!eagle!icdoc!cam-cl!am From: am@cl.cam.ac.uk (Alan Mycroft) Newsgroups: comp.lang.c Subject: Re: lint diagnostic Message-ID: <1130@jenny.cl.cam.ac.uk> Date: 20 Jan 88 18:04:59 GMT References: <365@osupyr.UUCP> <5304@iuvax.UUCP> Reply-To: am@cl.cam.ac.uk (Alan Mycroft) Organization: U of Cambridge Comp Lab, UK Lines: 34 [The last line is a query as to whether a full lint can be written!] In article <5304@iuvax.UUCP> bobmon@iuvax.UUCP (Bobmon) writes: >In article <365@osupyr.UUCP> gae@osupyr.UUCP (Gerald Edgar) writes: >+defmach(lo) int lo; [...] >+main() >+{ printf("sizeof(int) = %d\n",sizeof(int)); >+ printf("sizeof(long) = %d\n",sizeof(long)); >+ defmach(65535); >+ exit(0); } [Execution] >+sizeof(int) = 4; sizeof(long) = 4; 0000ffff [Lint] >+defmach, arg. 1 used inconsistently x.c(6) :: x.c(13) Doug Gwyn says.. >You passed it a long (65535 on a 16-bit machine) but it expects an int. I think a more correct explaination is that you have a non-matching cc and lint -- lint thinks sizeof(int) == 2 so that 65535 has type (long int) whereas cc thinks sizeof(int)==4 so that 65535 has type (int). You can test it by trying something like int a[256/(sizeof(int)-2)]; and seeing if lint splutters. Thus it would seem to be very hard indeed to write a lint which tries hard to find 'strictly conforming' ANSI programs -- each number above 0x7fff would be regarded as having two or more types: E.g. int x = 99999; is dubious if sizeof(int)==2 whereas printf("%ld", 99999) is dubious if sizeof(int)==4 (it may not work if sizeof(long)==8). Things become even harder with size_t/ptrdiff_t...