home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / libg_tex / hints next >
Encoding:
Emacs RMAIL  |  1991-11-16  |  19.5 KB  |  523 lines

  1. BABYL OPTIONS:
  2. Version: 5
  3. Labels:
  4. Note:   This is the header of an rmail file.
  5. Note:   If you are seeing it in rmail,
  6. Note:    it means the file has no messages in it.
  7. 1,,
  8. Return-Path: <riedl@cs.purdue.edu>
  9. Received: from oswego.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0)
  10.     id AA08377; Sun, 11 Feb 90 21:33:40 EST
  11. Received: by oswego.Oswego.EDU (5.57/Osw4.1.21)
  12.     id AA00896; Sun, 11 Feb 90 21:33:18 EST
  13. Received: from raid8.cs.purdue.edu by arthur.cs.purdue.edu (5.61/PURDUE_CS-1.2)
  14.     id <AA01233@arthur.cs.purdue.edu>; Sun, 11 Feb 90 21:30:14 -0500
  15. Received: from localhost by raid8.cs.purdue.edu (5.61/PURDUE_CS-1.2)
  16.     id <AA19140@raid8.cs.purdue.edu>; Sun, 11 Feb 90 21:30:08 -0500
  17. Message-Id: <9002120230.AA19140@raid8.cs.purdue.edu>
  18. To: dl@oswego.oswego.edu
  19. Subject: kudos for profiling and libg++
  20. In-Reply-To: Your message of Tue, 09 Jan 90 06:27:17 -0500.
  21.              <9001091127.AA09544@g.oswego.edu> 
  22. Date: Sun, 11 Feb 90 21:30:04 EST
  23. From: riedl@cs.purdue.edu
  24.  
  25. *** EOOH ***
  26. Return-Path: <riedl@cs.purdue.edu>
  27. To: dl@oswego.oswego.edu
  28. Subject: kudos for profiling and libg++
  29. In-Reply-To: Your message of Tue, 09 Jan 90 06:27:17 -0500.
  30.              <9001091127.AA09544@g.oswego.edu> 
  31. Date: Sun, 11 Feb 90 21:30:04 EST
  32. From: riedl@cs.purdue.edu
  33.  
  34. I was having some trouble with the performance of a concurrency
  35. controller I had written, and am very pleased to report that g++
  36. support for profiling, and the excellent libg++ data structure support
  37. saved the day!  I include a detailed description of the problem and
  38. solution below, which you are welcome to send to any of the involved
  39. parties for encouragement, or to publish for bragging rights (:-).
  40.  
  41. Nice job!
  42. John
  43. ------
  44. The basic problem was that two concurrency controllers that I had
  45. written, called T/O and Lock for short, should have had similar
  46. performance characteristics, but didn't.  After some days of work it
  47. became clear that T/O was significantly slower than Lock, for reasons
  48. that I couldn't understand.  I profiled the two routines and found the
  49. profiles to be very similar, as expected, with the exception of a
  50. large number of calls to compare_item in T/O:
  51.  
  52.     calls to compare_item       total time
  53. T/O    118,112       0.43               10.76 seconds
  54. LOCK    6601*[2-3] 0.09 seconds        9.02 seconds
  55.  
  56. (The numbers involved are small because I did the run for 100
  57. transactions.  Real runs will be for several orders of magnitude more
  58. transactions.) 
  59.  
  60. (I don't have an exact number for the number of calls to compare item
  61. for Lock for obscure reasons, but my understanding of the program
  62. makes me confident that it was called 2-3 times for each call to its
  63. parent, which was called 6601 times.)
  64.  
  65. The additional 1.74 seconds spent in T/O could almost all be accounted
  66. for by calls to compare_item and its parent, SLSet::seek.  Since the
  67. data structures involved were relatively small I expected that using a
  68. fancier data structure wouldn't help, but I thought I should test the
  69. potential.  I determined that the data structures involved would grow
  70. to about 300 items, and that items would be accessed much more often
  71. than they would be inserted.  So I timed versions using the linked
  72. list and using AVL trees:
  73.  
  74. program        items    accesses    seconds (user time)
  75. sl-set         300     10,000              7.70
  76. sl-set         300     10,000              7.61
  77. sl-set        3000     10,000             91.35
  78.  
  79. avl-set         300      1,000       0.18
  80. avl-set         300     10,000       0.68
  81. avl-set         300    100,000          6.15
  82. avl-set        3000     10,000          1.48
  83.  
  84. Clearly the AVL tree implementation was far superior, even for small
  85. problem sizes.  I installed the AVL sets in T/O and they solved the
  86. performance problem I was having.  Profiling shows that before the
  87. change:
  88.  
  89.     calls to compare_item       total time
  90. T/O    118,112       0.43               10.76 seconds
  91. LOCK    6601*[2-3] 0.09 seconds        9.02 seconds
  92.  
  93. After the change locking is the same, but:
  94.  
  95. T/O    16,048     0.10 seconds        9.08 seconds
  96.  
  97. The lessons I take from this study are:
  98.  
  99. 1) Linked lists may cause performance problems even if the lists are
  100. relatively short (< 100 items) if they are heavily used.
  101.  
  102. 2) The C++ library can be extremely advantageous.  In this case, I
  103. made a two line change to my program to change to AVL trees.
  104.  
  105. 3) Profiling is essential to understanding program performance.
  106.  
  107. John Riedl
  108.  
  109. 1,,
  110. Return-Path: <dl@g.oswego.edu>
  111. Received: from rocky.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0)
  112.     id AA03598; Thu, 8 Feb 90 05:50:05 EST
  113. Received: by oswego.Oswego.EDU (5.57/Osw4.1.21)
  114.     id AA08592; Thu, 8 Feb 90 05:47:12 EST
  115. Received: from life.ai.mit.edu by nisc.nyser.net (5.61/2.1-NYSERNet NISC)
  116.     id AA07649; Thu, 8 Feb 90 05:44:40 -0500
  117. Received: from oswego.Oswego.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA29896; Thu, 8 Feb 90 05:46:04 EST
  118. Received: by oswego.Oswego.EDU (5.57/Osw4.1.21)
  119.     id AA27161; Thu, 8 Feb 90 05:48:41 EST
  120. Received: by g.oswego.edu (4.0/SMI-4.0)
  121.     id AA03595; Thu, 8 Feb 90 05:48:50 EST
  122. Date: Thu, 8 Feb 90 05:48:50 EST
  123. From: dl@g.oswego.edu (Doug Lea)
  124. Message-Id: <9002081048.AA03595@g.oswego.edu>
  125. To: jose@csserver.cs.msstate.edu
  126. Cc: bug-lib-g++@prep.ai.mit.edu
  127. In-Reply-To: Jose Cordova's message of Wed, 7 Feb 90 17:28:57 CST <9002072328.AA07167@CSServer.CS.MsState.Edu>
  128. Subject: Run-time error when using 'get' with an istream object
  129. Reply-To: dl@oswego.oswego.edu
  130.  
  131. *** EOOH ***
  132. Return-Path: <dl@g.oswego.edu>
  133. Date: Thu, 8 Feb 90 05:48:50 EST
  134. From: dl@g.oswego.edu (Doug Lea)
  135. To: jose@csserver.cs.msstate.edu
  136. Cc: bug-lib-g++@prep.ai.mit.edu
  137. In-Reply-To: Jose Cordova's message of Wed, 7 Feb 90 17:28:57 CST <9002072328.AA07167@CSServer.CS.MsState.Edu>
  138. Subject: Run-time error when using 'get' with an istream object
  139. Reply-To: dl@oswego.oswego.edu
  140.  
  141.  
  142. > I am having trouble using the 'get' method for the 'istream' class.
  143. > It generates a 'Segmentation fault' error at run-time.  I know the
  144. > 'istream' is being opened correctly because reading into a 'String'
  145. > object with >> works fine.  Am I doing something wrong ?
  146. > The sample program and "data" illustrate the point:
  147. > main()
  148. > {
  149. >     istream from("data",io_readonly,a_useonly);
  150. >     char *line;
  151. >     from.get(line,15);
  152. >     cout << line;
  153. > }
  154. > Sample "data" file contents:
  155. > word1 word2
  156. > word3
  157.  
  158. There are 3 istream functions for reading char*'s 
  159.  
  160.   istream&      get    (char* s, int n, char terminator = '\n');
  161.   istream&      getline(char* s, int n, char terminator = '\n');
  162.   istream&      gets   (char **s, char terminator = '\n');
  163.  
  164. The first two *require* an allocated char* (they differ only
  165. in how the trailing terminator is handled.) To use them, you
  166. must supply either a char[N] or an allocated char*.
  167. The third automatically allocates space for you, that you should
  168. later delete.
  169.  
  170. For example,
  171.  
  172. main()
  173. {
  174.     istream from("data",io_readonly,a_useonly);
  175.     char *line = new char[16]; // enough for string + null
  176.     char line2[16];
  177.     char* line3 = 0; // `= 0' so delete'able even if never allocated --
  178.                      // Not necessary in this example.
  179.  
  180.     from.get(line,15);
  181.     from.get(line2,15);
  182.     from.gets(&line3,15);  // pass in the addr of line3
  183.  
  184.     cout << line;
  185.     cout << line2;
  186.     cout << line3;
  187.  
  188.     delete line;
  189.     delete line3;
  190. }
  191.  
  192. Using the String class is a very good way to avoid dealing with these
  193. kinds of char* allocation and semantics issues.
  194.  
  195. -Doug
  196.  
  197. 1, answered,,
  198. Return-Path: <chowkwan@aerospace.aero.org>
  199. Received: from aerospace.aero.org ([130.221.192.10]) by g.oswego.edu (4.0/SMI-4.0)
  200.     id AA03846; Mon, 5 Feb 90 16:10:27 EST
  201. Received: from antares.aero.org by aerospace.aero.org with SMTP (5.61++/6.0.GT)
  202.     id AA24377 for dl@g.oswego.edu; Mon, 5 Feb 90 13:06:58 -0800
  203. Posted-Date: Mon, 5 Feb 90 13:06:50 PST
  204. Received: from merlin.aero.org by antares.aero.org (4.1/SMI-3.2-A4ant)
  205.     id AA20056 for dl@g.oswego.edu; Mon, 5 Feb 90 13:06:55 PST
  206. Message-Id: <9002052106.AA20056@antares.aero.org>
  207. Received: by merlin.aero.org (4.1/SMI-3.2-A4)
  208.     id AA03654 for dl@g.oswego.edu; Mon, 5 Feb 90 13:06:50 PST
  209. Date: Mon, 5 Feb 90 13:06:50 PST
  210. From: chowkwan@aerospace.aero.org
  211. To: dl@g.oswego.edu
  212. Subject: Checklist for using Map class
  213.  
  214. *** EOOH ***
  215. Return-Path: <chowkwan@aerospace.aero.org>
  216. Posted-Date: Mon, 5 Feb 90 13:06:50 PST
  217. Date: Mon, 5 Feb 90 13:06:50 PST
  218. From: chowkwan@aerospace.aero.org
  219. To: dl@g.oswego.edu
  220. Subject: Checklist for using Map class
  221.  
  222.  
  223. I found your last message of Jan 20 was enough to get me
  224. started using the Map class.  I'm attaching some notes
  225. I made in LaTeX format which are intended to get new
  226. users off and running quickly.  It's pretty much in the
  227. form of a checklist that they can just go down and follow.
  228. I was thinking it might be useful to you as a standard
  229. response to inquiries for help from neophytes like myself.
  230.  
  231.                0          cut here        0
  232. ----------------><--------------------------------><------------------
  233.                0                                    0
  234.  
  235. \documentstyle{article}
  236. \title{Implementing Table Lookup Using the GNU Library}
  237. \begin{document}
  238. \section{Introduction}
  239.  
  240. This note describes how to use the GNU class library Version 1.35.0
  241. to create lookup tables.  
  242. The advantage of using the GNU library is that 
  243. the code to implement tables can be quickly generated.
  244. Hopefully, the code is also more reliable than
  245. what we could write ourselves.
  246. In addition, the library provides four different lookup
  247. mechanisms. It is relatively easy to ``switch engines''
  248. and use the fastest one for our application.
  249.  
  250. This note augments the ``User's Guide to GNU C++ Library''
  251. by filling in some gaps in the manual.
  252. Therefore, it is intended to complement, rather than
  253. replace the original manual.
  254. Section \ref{sec:general} describes the general procedure
  255. for creating a lookup table.  
  256. Section \ref{sec:specific} gives a working example, in this
  257. case the creation of a lookup table for database objects.
  258.  
  259.  
  260. \section{Using the GNU Library to Create a Lookup Table}
  261. \label{sec:general}
  262.  
  263. The GNU library provides four implementations of lookup tables:
  264. threaded AVL trees, splay trees, resizable hash tables, and
  265. chained hash tables.
  266. The hash table implementations provide double hashing.
  267. The class names for these implementations are shown below
  268. in Table \ref{tab:imp}.
  269. All four classes are subclasses of the {\tt Map} class. \\
  270. Therefore, to create a lookup table, you must define a table class based 
  271. on the abstract class {\tt Map} as well as one of the subclasses.
  272. The script {\tt genclass}, provided
  273. with the GNU library, automates this process.
  274.  
  275. \begin{table}[htb]
  276. \centering
  277. \caption{\label{tab:imp} GNU Implementations of Lookup Tables}
  278. \begin{tabular}{||l|l||} \hline
  279. {\bf Class Name} & {\bf Implementation Method} \\ \hline
  280. {\tt AVLMap} & Threaded AVL trees. \\
  281. {\tt SplayMap} & Splay trees. \\
  282. {\tt VHMap} & Resizable hash tables. \\
  283. {\tt CHMap} & Chained hash tables. \\ \hline
  284. \end{tabular} \\
  285. \end{table} 
  286.  
  287.  
  288.  
  289. A {\sl key} refers to the index for the table
  290. and {\sl base value} refers to the basic data
  291. stored in the table that is returned upon
  292. a keyed lookup.
  293. You need to define a hashing function 
  294. and an equality function for the key.
  295. Finally, if you use pointers as your base
  296. value you need to typedef a name for the pointer.
  297. The steps you need to take are shown below.
  298. In these examples, {\tt $<$K$>$} is the name
  299. of the key class, 
  300. {\tt $<$B$>$} the name of the class for the base value,
  301. {\tt $<$BP$>$} the name of the type pointer to base value,
  302. and {\tt $<$M$>$} the name of one of the four {\tt Map} subclasses. \\
  303.  
  304. \begin{tabular}{||r|l|l||} \hline
  305. &&  {\bf Name of } \\
  306. {\bf Step} & {\bf Action} & {\bf Affected File} \\  \hline
  307. 1 & Create functions {\tt $<$K$>$HASH} & {\tt $<$K$>$.defs.h} \\
  308.   & and {\tt $<$K$>$EQ}. &{\tt $<$K$>$.defs.cc }  \\ \hline
  309. 2 & Define {\tt DEFAULT\_INITIAL\_CAPACITY} & {\tt $<$K$>$.defs.h} \\ \hline
  310. 3 & Create typedef {\tt $<$BP$>$}. & {\tt  $<$B$>$.h}  \\
  311.   & for  pointer to base class. & \\ \hline
  312. 4 & Create abstract class with  & {\tt $<$K$>$.$<$BP$>$.Map.h}  \\
  313.   & {\tt genclass -2 $<$K$>$ ref $<$BP$>$ val Map}& 
  314.   {\tt $<$K$>$.$<$BP$>$.Map.cc} \\ \hline
  315. 5 & Edit {\tt $<$K$>$.$<$BP$>$.Map.h} to include &{\tt $<$K$>$.$<$BP$>$.Map.h} \\
  316.   & {\tt $<$K$>$.defs.h} and {\tt  $<$B$>$.h}. &   \\ \hline
  317. 6 & Create table class for specific & {\tt $<$K$>$.$<$BP$>$.$<$M$>$.h} \\
  318.   & lookup implementation method with & {\tt $<$K$>$.$<$BP$>$.$<$M$>$.cc} \\ 
  319.   & {\tt genclass -2 $<$K$>$ ref $<$BP$>$ val $<$M$>$ } & \\ \hline
  320. \end{tabular} \\
  321.  
  322. The {\tt $<$K$>$} and {\tt $<$BP$>$} arguments to {\tt genclass}
  323. can be qualified by either {\tt val} or {\tt ref} depending on
  324. whether the reference is by value or by reference.
  325.  
  326. \section{Example: Table Lookup Class for Database Objects}
  327. \label{sec:specific}
  328.  
  329. In this example, we want to refer to objects from the 
  330. user-defined class {\tt Database} by their names so
  331. the name of the database object is the key to the table.
  332. To accommodate the {\tt Map} class need for   hashing on the key,
  333. the name is represented by a {\tt String} and the
  334. hash function is the library {\tt hashpjw} function
  335. declared in {\tt builtin.h}
  336. Thus {\tt $<$K$>$} is {\tt String},
  337. {\tt $<$B$>$} is {\tt Database}, and
  338. {\tt $<$BP$>$} is {\tt Databasep}.
  339. For this example, the lookup mechanism used is resizable
  340. hash tables which have type {\tt VHMap} so
  341. {\tt $<$M$>$} is {\tt VHMap}.
  342.  
  343. \begin{enumerate}
  344. \item The {\tt Map} classes expect to get
  345. a function called {\tt HStringHASH} 
  346. that takes an argument of type {\tt String} 
  347. so {\tt hashpjw} was wrapped inside
  348. {\tt HStringHASH}.  
  349. Similarly, {\tt HStringEQ} is a wrapper
  350. for the {\tt HString} class operator $=$.
  351. (The $=$ operator is inherited from the {\tt String}
  352. class).
  353. The function headers 
  354. for {\tt HStringHASH} and {\tt HStringEQ} 
  355. go into {\tt HString.defs.h}
  356. and the function bodies into {\tt HString.defs.cc}.
  357.  
  358.  
  359. \item {\tt DEFAULT\_INITIAL\_CAPACITY} was set to {\tt 1021}
  360. in {\tt HString.defs.h}.  You must use the identifier
  361. {\tt DEFAULT\_INITIAL\_CAPACITY} to be consistent with
  362. the {\tt Map} classes.
  363.  
  364. \item Define {\tt Databasep} as a pointer to class
  365. {\tt Database} in {\tt Database.h}.
  366. An identifier other than {\tt Databasep} would
  367. also be acceptable.  You just can't use {\tt Database*}.
  368.  
  369. \item {\tt genclass -2 HString ref Databasep val Map} \\
  370. produces {\tt HString.Databasep.Map.h} and \\
  371. {\tt HString.Databasep.Map.cc}.
  372.  
  373. \item Edit {\tt HString.Databasep.Map.h} to
  374. include {\tt HString.defs.h} and  \\ {\tt Database.h}.
  375.  
  376. \item {\tt genclass -2 HString ref Databasep val VHMap} \\
  377. produces {\tt HString.Databasep.VHMap.h} and \\
  378. {\tt HString.Databasep.VHMap.cc}.
  379. \end{enumerate}
  380.  
  381.  
  382. \end{document}
  383.  
  384.  
  385.  
  386.  
  387.  
  388. 1,,
  389. Return-Path: <dl@g.oswego.edu>
  390. Received: from rocky.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0)
  391.     id AA26086; Sat, 3 Feb 90 07:05:17 EST
  392. Received: by oswego.Oswego.EDU (5.57/Osw4.1.19)
  393.     id AA09020; Sat, 3 Feb 90 07:04:44 EST
  394. Received: from life.ai.mit.edu by nisc.nyser.net (5.61/2.1-NYSERNet NISC)
  395.     id AA24615; Sat, 3 Feb 90 07:00:07 -0500
  396. Received: from oswego.Oswego.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA04153; Sat, 3 Feb 90 07:00:15 EST
  397. Received: by oswego.Oswego.EDU (5.57/Osw4.1.19)
  398.     id AA16111; Sat, 3 Feb 90 07:02:52 EST
  399. Received: by g.oswego.edu (4.0/SMI-4.0)
  400.     id AA26081; Sat, 3 Feb 90 07:03:03 EST
  401. Date: Sat, 3 Feb 90 07:03:03 EST
  402. From: dl@g.oswego.edu (Doug Lea)
  403. Message-Id: <9002031203.AA26081@g.oswego.edu>
  404. To: ngo%tammy@harvard.harvard.edu
  405. Cc: bug-lib-g++@prep.ai.mit.edu
  406. In-Reply-To: Tom Ngo's message of Fri, 2 Feb 90 23:42:54 EST <9002030548.AA00886@life.ai.mit.edu>
  407. Subject: Should "operator =" be made to return *this, by convention?
  408. Reply-To: dl@oswego.oswego.edu
  409.  
  410. *** EOOH ***
  411. Return-Path: <dl@g.oswego.edu>
  412. Date: Sat, 3 Feb 90 07:03:03 EST
  413. From: dl@g.oswego.edu (Doug Lea)
  414. To: ngo%tammy@harvard.harvard.edu
  415. Cc: bug-lib-g++@prep.ai.mit.edu
  416. In-Reply-To: Tom Ngo's message of Fri, 2 Feb 90 23:42:54 EST <9002030548.AA00886@life.ai.mit.edu>
  417. Subject: Should "operator =" be made to return *this, by convention?
  418. Reply-To: dl@oswego.oswego.edu
  419.  
  420.  
  421. >     C programmers are accustomed to expecting = to return the value
  422. >     assigned.  However, in a few classes--for example, String, Integer
  423. >     and Rational-- operator == returns void.  Is there a good reason
  424. >     for this?  Could they be made to return String&, Integer& and
  425. >     Rational& *this without causing problems?
  426.  
  427. The reason that X= (+=, -=, etc.) and = operators return void is to
  428. facilitate simple subclassing. While `utility' classes like String,
  429. Integer, etc., are not designed for extensive subclassing (since no
  430. members are virtual (which, in turn is motivated by efficiency
  431. considerations)), it is often convenient to create simple subclasses
  432. like class Line : public String. If you do this, then it is most
  433. desirable that inherited operators return void.  Otherwise, unexpected
  434. type matches often occur. For example, if operator << (ostream&,
  435. Line&) were redefined for Line, but op += were inherited from String,
  436. and had return value String&, then
  437.     { Line l; ...;  cout << (l += "\n"); } 
  438. would invoke op << (ostream&, String&), which is probably not
  439. what anyone would have in mind.  This is avoided by having String::+=
  440. return void, making this usage illegal.
  441.  
  442. Problems like this outweigh the syntactic convenience of supporting
  443. multiple right-associative uses of X= and =. A good rule of thumb
  444. about all this is that no non-virtual member functions should
  445. ever return *this by reference. (This rule is broken in a few places
  446. in libg++ for various reasons though.)
  447.  
  448. -Doug
  449.  
  450. 1,,
  451. Return-Path: <dl@g.oswego.edu>
  452. Received: from rocky.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0)
  453.     id AA00741; Thu, 18 Jan 90 06:01:53 EST
  454. Received: by oswego.Oswego.EDU (5.57/Osw4.1.18)
  455.     id AA22159; Thu, 18 Jan 90 06:02:51 EST
  456. Received: from life.ai.mit.edu by nisc.nyser.net (5.61/2.1-NYSERNet NISC)
  457.     id AA22988; Thu, 18 Jan 90 05:56:52 -0500
  458. Received: from oswego.Oswego.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA00267; Thu, 18 Jan 90 05:58:24 EST
  459. Received: by oswego.Oswego.EDU (5.57/Osw4.1.18)
  460.     id AA16327; Thu, 18 Jan 90 06:01:51 EST
  461. Received: by g.oswego.edu (4.0/SMI-4.0)
  462.     id AA00738; Thu, 18 Jan 90 06:00:57 EST
  463. Date: Thu, 18 Jan 90 06:00:57 EST
  464. From: dl@g.oswego.edu (Doug Lea)
  465. Message-Id: <9001181100.AA00738@g.oswego.edu>
  466. To: allen@sscvx1.ssc.gov
  467. Cc: bug-lib-g++@prep.ai.mit.edu
  468. In-Reply-To: Michael Allen's message of Wed, 17 Jan 90 14:56:32 CST <9001172056.AA01056@mdtf05.gov>
  469. Subject: compiling libg++-1.36.3 with g++-1.36.3 on sun4
  470. Reply-To: dl@oswego.oswego.edu
  471.  
  472. *** EOOH ***
  473. Return-Path: <dl@g.oswego.edu>
  474. Date: Thu, 18 Jan 90 06:00:57 EST
  475. From: dl@g.oswego.edu (Doug Lea)
  476. To: allen@sscvx1.ssc.gov
  477. Cc: bug-lib-g++@prep.ai.mit.edu
  478. In-Reply-To: Michael Allen's message of Wed, 17 Jan 90 14:56:32 CST <9001172056.AA01056@mdtf05.gov>
  479. Subject: compiling libg++-1.36.3 with g++-1.36.3 on sun4
  480. Reply-To: dl@oswego.oswego.edu
  481.  
  482.  
  483.  
  484. > 2) several files get flagged as a warning that a volatile funtion does
  485. > return, which appears to be false.
  486.  
  487. Not quite false, but deserving of explanation:
  488.  
  489. libg++ does not (yet) use the experimental g++ exception handling
  490. facilities (they are still too new: Too many things would have to be
  491. redone if the EH features change). So the only exception strategy is
  492. for error traps like Integer::error() to call the function pointed to
  493. by lib_error_handler (see builtin.h). By default, this points to
  494. default_two_arg_error_handler, which prints a message on stderr and
  495. aborts. But it *can* be reset to do anything at all, and need not
  496. abort execution. On the other hand, *some* (not all) error() member
  497. functions are used in a way that preclude any kind of sensible
  498. continuation even if error() returns. I mark these as `volatile',
  499. since the compiler might as well act as if they cannot return: This is
  500. defensible in that even if (*lib_error_handler) returns, things are
  501. going so wrong that you are no worse off if the compiler generates
  502. (usually faster) code assuming execution aborts.  The compiler
  503. correctly warns about these.
  504.  
  505. Again, saner strategies will be employed when the C++ exception
  506. handling situation stabilizes.
  507.  
  508. -Doug
  509.  
  510.  
  511.