Re: A lesson for compiler warning writers

arnold@cc.gatech.edu (Arnold Robbins)
Thu, 18 Jun 1992 17:13:39 GMT

          From comp.compilers

Related articles
A lesson for compiler warning writers Garrett.Wollman@UVM.EDU (1992-06-10)
Re: A lesson for compiler warning writers mcdaniel@adi.com (1992-06-12)
Re: A lesson for compiler warning writers tmb@arolla.idiap.ch (1992-06-17)
Re: A lesson for compiler warning writers maniattb@cs.rpi.edu (1992-06-17)
Re: A lesson for compiler warning writers stephen@estragon.uchicago.edu (1992-06-18)
Re: A lesson for compiler warning writers arnold@cc.gatech.edu (1992-06-18)
Re: A lesson for compiler warning writers xjam@cork.CS.Berkeley.EDU (1992-06-18)
Re: A lesson for compiler warning writers hays@ssd.intel.com (1992-06-18)
Re: A lesson for compiler warning writers kendall@centerline.com (1992-06-19)
Re: A lesson for compiler warning writers wicklund@intellistor.com (1992-06-18)
Re: A lesson for compiler warning writers dds@doc.imperial.ac.uk (Diomidis Spinellis) (1992-06-19)
Re: A lesson for compiler warning writers hagerman@ece.cmu.edu (1992-06-19)
[9 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: arnold@cc.gatech.edu (Arnold Robbins)
Keywords: lint, design
Organization: Georgia Institute of Technology
References: <19920609091040SEB1525@MVS.draper.com> 92-06-075
Date: Thu, 18 Jun 1992 17:13:39 GMT

maniattb@cs.rpi.edu (Bill Maniatty) writes:
>You have to be sure that the tool that does the checking is 100 %
>compliant with the compiler. I think the best way to do that is to make
>the compiler rigorous in its checking. This also serves the purpose to
>make sure that the compiler user knows that there is something about the
>code that the compiler does not like.


I have said this before, in different forums, but perhaps not as clearly.
Rigorous compiler checking is a Good Thing, but it is not enough. No C
compiler in the world will do cross file checking for you, only lint does
it. If you have:


file a.c:


double foo(long a) { return a * 2.0 ; }


file b.c


#include <stdio.h>
extern short foo(double a);
int main(void) { printf("%d\n", foo(1.0)); return 0; }


Both files will compile just fine. Even the second one, since there are
prototypes etc. available. But when you link the two objects together,
the output will be either garbage or a core dump. lint will catch this,
the C compiler won't. For this reason, lint is not only good, it's
necessary.


Yes, prototypes help. Yes, no-one should write code like this. People
do anyway. As they say, "lint is your friend".
--
Arnold Robbins --- College of Computing
Georgia Tech, Atlanta, GA 30332-0280
Domain: arnold@cc.gatech.edu Phone: +1 404 894 9214
UUCP: uunet!cc.gatech.edu!arnold FAX: +1 404 853 9378
[I've always wondered how hard it would be to have a declarations database
that compilers could consult and update as they compiled stuff. That must
be a standard CASE thing. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.