🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1633

Re: Linkage revisited

#1633
From: Fergus Henderson
Date: Wed, 02 Aug 1995 15:10
39 lines
2000 bytes
greghunt@zeta.org.au writes:

> We are not attempting to support linkage between compilers - which is
> both unfortunate and too hard - but we have the prospect of different
> linkages being generated by the same compiler at different times -
> which seems unnecessary.

That is a *very* good point.

Regardless of whether or not a C++ compiler is or is not required to
support interfacing with C, a stand-alone C++ program may contain
"C" linkage-specifications.  The C++ standard *must* make it clear
whether or not a program such as the following is strictly conforming.

	void foo(void (*func)()) { (*func)(); }
	void bar() {}
	extern "C" void baz() {}

	int main() {
		foo(bar);
		foo(baz);
		return 0;
	}

According to my reading of the ARM and the current draft standard, this
program is strictly conforming.  The semantics of the `foo(baz)' are
well-defined for exactly the same reason that the semantics of `foo(bar)' are
well-defined.

I think it would be a bad mistake if there committee were to decide to
disallow this program, or give it undefined behaviour.
It would break a significant amount of code and impose a continuing
hardship on C++ programmers, with very few compensating benefits.

-- 
Fergus Henderson              | Designing grand concepts is fun;
fjh@cs.mu.oz.au               | finding nitty little bugs is just work.
http://www.cs.mu.oz.au/~fjh   | -- Brooks, in "The Mythical Man-Month".
PGP key fingerprint: 00 D7 A2 27 65 09 B6 AC  8B 3E 0F 01 E7 5D C4 3F
Technical Details
Message-ID: <9521501.4885@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!munta.cs.mu.OZ.AU!fjh
References: <bill_law-1807951030140001@bill-law.taligent.com> <KANZE.95Jul25103036@slsvhdt.lts.sel.alcatel.de> <3v82hd$gsc@godzilla.zeta.org.au>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Linkage revisited
Message-ID: <9521501.4885@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <bill_law-1807951030140001@bill-law.taligent.com> <KANZE.95Jul25103036@slsvhdt.lts.sel.alcatel.de> <3v82hd$gsc@godzilla.zeta.org.au>
Date: Wed, 2 Aug 1995 15:10:05 GMT