home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1884 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.4 KB  |  51 lines

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