home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
- Subject: Re: Pointer comparisons
- Message-ID: <9235706.2271@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- References: <BzDs2x.wA@frumious.uucp> <1992Dec17.151642.9954@bcrka451.bnr.ca> <1992Dec18.181029.1061@taumet.com> <1gt9qjINNsrr@darkstar.UCSC.EDU>
- Date: Mon, 21 Dec 1992 19:17:55 GMT
- Lines: 39
-
- daniel@cse.ucsc.edu (Daniel R. Edelson) writes:
-
- >There's also a problem regarding inline functions.
- >Specifically, under common file-based C++ implementations,
- >the address of an inline function can vary between
- >compilation units. Thus, the requirement from
- >Ansi C (Sec 3.3.9)
- > ``If two pointers to function types ... both point to
- > the same function, they compare equal.''
- >is false under common C++ implementations.
-
- Actually, these implementations are correct. Inline non-member functions have
- internal linkage, and thus an inline function in one compilation unit
- is a different function to even a lexically identical inline function in
- a different compilation unit. (Inline member functions however are a
- whole different can of worms.)
-
- Does ANSI C require that pointers to different functions
- will compare unequal? If so, it is not the common C++ implementations
- that are the difficulty, it is the more sophisticated C++ implementations
- (such as Borland C++ with the "Smart Inlines" flag enabled) that use
- smart linkers or other techniques to avoid generating multiple copies
- of inline functions.
-
- Personally I believe that the default internal linkage for inline
- non-member functions was a mistake, brought about by letting the
- original implementation dictate too strongly the semantics of the
- language. Even if it is perhaps too late to change this, the ANSI C++
- standard should definitely not require that pointers to different
- functions compare unequal, because that would prevent a useful
- optimization, with no real gain. It should be enough to require
- that if f and g are function pointers of the same type for which
- f==g, then (*f)(...) has the same effect as (*g)(...).
-
- --
- Fergus Henderson fjh@munta.cs.mu.OZ.AU
- This .signature virus is a self-referential statement that is true - but
- you will only be able to consistently believe it if you copy it to your own
- .signature file!
-