Re: A lesson for compiler warning writers

Diomidis Spinellis <dds@doc.imperial.ac.uk>
Fri, 19 Jun 1992 14:49:47 GMT

          From comp.compilers

Related articles
[4 earlier articles]
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)
Re: A lesson for compiler warning writers igor!voltaire!davidm@uunet.UU.NET (1992-06-19)
Re: A lesson for compiler warning writers dww@inf.fu-berlin.de (1992-06-20)
Re: A lesson for compiler warning writers preston@dawn.cs.rice.edu (1992-06-21)
Re: A lesson for compiler warning writers mjr@decuac.DEC.COM (1992-06-22)
Re: A lesson for compiler warning writers prener@watson.ibm.com (1992-06-22)
[4 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: Diomidis Spinellis <dds@doc.imperial.ac.uk>
Keywords: C, lint
Organization: Compilers Central
Date: Fri, 19 Jun 1992 14:49:47 GMT

arnold@cc.gatech.edu (Arnold Robbins) writes:
> file a.c:
> double foo(long a) { return a * 2.0 ; }
> file b.c
> extern short foo(double a);
[...]
> Both files will compile just fine. [...] 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.


There are methods to catch this at link time, with existing linker
technology.. See pp. 122-127 Margaret A. Ellis and Bjarne Stroustrup,
The Annotated C++ Reference Manual, Addison-Wesley, 1990 and Diomidis
Spinellis, Type-safe Linkage for Variables and Functions SIGPLAN
Notices 26(8):74-79, August 1991.


Diomidis
--
Diomidis Spinellis Internet: <dds@doc.ic.ac.uk> UUCP: ...!ukc!icdoc!dds
Department of Computing, Imperial College, London SW7
[Good point. In about 1975, when Dartmouth College wrote their first linker
to go with the PL/I compiler (the other compilers were so fast that it wasn't
worth saving object code, much less linking) and they had a type matching
hack: The compiler annotated each external definition and reference with
a string of type data, and the linker complained if the type strings weren't
the same. Simple, fast, and effective. I presume the C++ approach is
similar, albeit with the type info encoded in the symbol name. -John]
--


Post a followup to this message

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