Re: A lesson for compiler warning writers

igor!voltaire!davidm@uunet.UU.NET (David Moore)
Fri, 19 Jun 1992 16:37:28 GMT

          From comp.compilers

Related articles
[6 earlier articles]
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)
Re: A lesson for compiler warning writers derek@knosof.uucp (1992-06-22)
Re: A lesson for compiler warning writers kendall@centerline.com (1992-06-23)
[2 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: igor!voltaire!davidm@uunet.UU.NET (David Moore)
Keywords: lint, design, C++
Organization: Compilers Central
References: <19920609091040SEB1525@MVS.draper.com> 92-06-084
Date: Fri, 19 Jun 1992 16:37:28 GMT



arnold@cc.gatech.edu (Arnold Robbins) writes:
[C doesn't catch type mismatches in separately compiled modules.]


In a language like C, which was never designed to promote consistency
across compilation units (unlike the Modula familly and Ada), a good
compiler can reduce this problem by generating link names with type
information appended to them. This idea dates back at least to the
mid-seventies, though at that time, the technique could not be used on
most machines because external names were limited to a small number of
characters by the linker.


In C++, you have to use this technique since procedures can be overloaded,
so the name does not uniquely define a procedure. An external linker will
require a unique identifer for each procedure.


As far as I can see, though, this technique limits you to using structural
equivalence for types. In languages like Ada, if I declare:
      A:ARRAY(1..10) OF CHARACTER;
      B:ARRAY(1..10) OF CHARACTER;


Then A and B have different types (because their types have different
(anonymous) names). With name equivalence, I would get a different type
for A in every compilation unit. The reliance on structural equivalence is
a significant difficulty in C++ (see, for example, Bjarne Stroustrup "The
C++ Programming Language" section 4.2 "Linkage" (page 110 in the second
edition)
--


Post a followup to this message

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