[gnu.g++.bug] Error compiling etc in libg++ 1.34 with gcc 1.34 on Sun4/260

schmidt@siam.ics.uci.edu (Doug Schmidt) (03/11/89)

In article <4347@psuvax1.cs.psu.edu> ehrlich@shire.cs.psu.edu () writes:
++ When I tried to compile etc in libg++ 1.34 with gcc 1.34 on a Sun
++ 4/260 under SunOS 4.0 the 'tests' make target fails with the following
++ error:
++ Patricia.h:66: warning: class Trie_Node only defines private constructors
++ In function int main (int, char **):
++ Patmain.cc:17: parse error before `return'
++ Patmain.cc:28: parse error before `return'

This resulted from an overzealous emacs global replace, I believe!
(This brings up a useful C++ tip, BTW.  When declaring class variables
with constructors and destructors locally in the main function of a
program it is usually best to pass a status value back to the shell
using `return' rather than `exit.'  Calling exit will result in any
local destructors not being envoked, since it is a function that never
returns.  When C++ has proper exception handling this problem should
go away (but don't hold your breath ;-)).

The fix is included below.  Thanks for reporting this, and please
remember to send future libg++ bug reports to the gnu.g++.lib.bug
newsgroup.

Doug

----------------------------------------
*** Patmain.cc.~1~	Thu Mar  9 03:53:48 1989
--- Patmain.cc	Fri Mar 10 14:30:00 1989
***************
*** 14,20 ****
     }
     else {
        if ( ! freopen ( argv [ 1 ], "r", stdin ) ) {
!          perror ( argv [ 0 ] ), return;
        }
        Patricia_Trie Trie;
        char Key [ Max_Key_Len ];
--- 14,20 ----
     }
     else {
        if ( ! freopen ( argv [ 1 ], "r", stdin ) ) {
!          perror ( argv [ 0 ] ); return ( 1 );
        }
        Patricia_Trie Trie;
        char Key [ Max_Key_Len ];
***************
*** 25,31 ****
  
        fclose ( stdin );
        if ( ! freopen ( argv [ 2 ], "r", stdin ) ) {
!          perror ( argv [ 0 ] ), return;
        }
  
        start_timer ();
--- 25,31 ----
  
        fclose ( stdin );
        if ( ! freopen ( argv [ 2 ], "r", stdin ) ) {
!          perror ( argv [ 0 ] ); return ( 1 );
        }
  
        start_timer ();
----------------------------------------
--
schmidt@ics.uci.edu (ARPA) |   Per me si va nella citta' dolente.
office: (714) 856-4043     |   Per me si va nell'eterno dolore.
                           |   Per me si va tra la perduta gente.
                           |   Lasciate ogni speranza o voi ch'entrate.