From octave-maintainers-request at bevo dot che dot wisc dot edu Tue Jun 19 14:57:38 2001 Subject: [patch] Octave CVS and GCC 3.0 From: Mumit Khan To: octave-maintainers at bevo dot che dot wisc dot edu cc: Mumit Khan Date: Tue, 19 Jun 2001 14:57:35 -0500 (CDT) [ I'm not subscribe to this list, so please copy me if appropriate ] Here's a quick patch to Octave CVS for a successful GCC 3.0 build. Two regressions: 1. io/fopen-1.m: This is a bug in the 'a+' file mode, ie., ios::in | ios::out | ios::app, in libstdc++-v3 (true on GNU/Linux at least, other platforms may vary); other modes work just fine. 2. poly/residue-1.m: This is a bit creepy, and I'm not sure who to blame. octave:1> b = [1, 1, 1]; octave:2> a = [1, -5, 8, -4]; octave:3> [r, p, k, e] = residue (b, a); Values for k and e are the same in all cases, so omitting that. Note the values for `p', which is what's causing the failure. Octave 2.0.16 + egcs-1.1.2: octave:4> r r = -2.00000000000000 7.00000000000000 3.00000000000000 octave:5> p p = 1.999999999999999 1.999999999999999 0.999999999999999 Octave CVS + egcs-1.1.2: octave:4> r r = -1.99999999999998 6.99999999999998 2.99999999999998 octave:5> p p = 2.000000000000000 2.000000000000000 0.999999999999998 Octave CVS + gcc-3.0: octave:4> r r = -2.00000000000000 6.99999987789050 3.00000000000000 octave:5> p p = 1.999999938945250 2.000000061054752 1.000000000000000 The test ``abs (p - [2; 2; 1]) < sqrt (eps)'' fails for gcc3 build, but works for the other builds. src/ChangeLog: 2001-06-19 Mumit Khan * c-file-ptr-stream.h (c_file_ptr_buf::c_file_ptr_buf): Add GCC3 libstdc++-v3 support. * load-save.cc (save_mat5_binary_element): Cast arguments to the correct type. (save_ascii_data): Eliminate compiler warning. * toplev.cc (system): Prefix std::. Index: src/c-file-ptr-stream.h =================================================================== RCS file: /cvs/octave/src/c-file-ptr-stream.h,v retrieving revision 1.5 diff -u -3 -p -r1.5 c-file-ptr-stream.h --- src/c-file-ptr-stream.h 2001/02/06 01:57:03 1.5 +++ src/c-file-ptr-stream.h 2001/06/19 18:17:03 at @ -46,11 +46,10 @@ public: c_file_ptr_buf (FILE *f_arg, close_fcn cf_arg = ::fclose) : -#ifdef __SUNPRO_CC - std::filebuf (f_arg ? fileno (f_arg) : -1), +#if defined __GNUC__ && __GNUC__ >= 3 + std::filebuf (f_arg, std::ios::in | std::ios::out), #else - std::filebuf (f_arg ? fileno (f_arg) : -1, - 0, std::ios::in | std::ios::out), + std::filebuf (f_arg ? fileno (f_arg) : -1), #endif f (f_arg), cf (cf_arg), fd (f_arg ? fileno (f_arg) : -1) Index: src/load-save.cc =================================================================== RCS file: /cvs/octave/src/load-save.cc,v retrieving revision 1.135 diff -u -3 -p -r1.135 load-save.cc --- src/load-save.cc 2001/05/31 19:30:51 1.135 +++ src/load-save.cc 2001/06/19 18:06:01 at @ -4254,7 +4254,8 @@ save_mat5_binary_element (std::ostream& contin = os.tellp (); os.seekp (fixup); - write_mat5_tag (os, miMATRIX, contin - fixup - 8); // the actual length + write_mat5_tag (os, miMATRIX, + static_cast(contin - fixup) - 8); // the actual length os.seekp (contin); return true; at @ -4473,7 +4474,7 @@ save_ascii_data (std::ostream& os, const os << "# elements: " << elements << "\n"; for (int i = 0; i < elements; i++) { - int len = chm.cols (); + unsigned len = chm.cols (); os << "# length: " << len << "\n"; std::string tstr = chm.row_as_string (i, false, true); const char *tmp = tstr.data (); Index: src/toplev.cc =================================================================== RCS file: /cvs/octave/src/toplev.cc,v retrieving revision 1.103 diff -u -3 -p -r1.103 toplev.cc --- src/toplev.cc 2001/05/17 13:45:42 1.103 +++ src/toplev.cc 2001/06/19 18:06:01 at @ -482,7 +482,7 @@ variable @code{status} to the integer @s // kpathsearch library to not always do TeX-specific // things... - static string odb; + static std::string odb; odb = octave_env::getenv ("TEXMFDBS"); Regards, Mumit