From octave-maintainers-request at bevo dot che dot wisc dot edu Mon Apr 9 13:19:16 2001 Subject: [patch] small tweaks for ISO C++ compliance, Sun C++ bug From: Mumit Khan To: octave-maintainers at bevo dot che dot wisc dot edu cc: Mumit Khan Date: Mon, 9 Apr 2001 13:19:13 -0500 (CDT) Two simple tweaks - ISO C++ does not require an operator+ for streampos or fpos and an integral type [ See 27.4.3.2/1 for fpos requirements ]. The following testcase shows what the problem is: #include void foo() { std::streampos pos; long foo1; int foo2; // FOUR_BYTE_INT pos + foo1; // OK pos + foo2; // not OK, ambiguous pos + static_cast (foo2); // OK } This problem will show up using gcc versions >= -3.0. - DLD-FUNCTIONS/det.cc runs into a bug in Sun Workshop compilers -- no default conversion for the arguments of ?: operator. Patch against current CVS tree. 2000-04-09 Mumit Khan * load-save.cc (read_mat5_binary_element): Cast arguments to the correct type when adding stream positions. * DLD-FUNCTIONS/det.cc (det): Explicity create a Complex value to work around a Sun C++ type conversion bug. Index: src/load-save.cc =================================================================== RCS file: /cvs/octave/src/load-save.cc,v retrieving revision 1.133 diff -u -3 -p -r1.133 load-save.cc --- src/load-save.cc 2001/02/14 05:50:37 1.133 +++ src/load-save.cc 2001/04/09 18:13:39 at @ -2545,7 +2545,7 @@ read_mat5_binary_element (std::istream& // delay checking for a multidimensional array until we have read // the variable name - is.seekg (pos + dimension_length); + is.seekg (pos + static_cast (dimension_length)); } // array name subelement at @ -2567,7 +2567,7 @@ read_mat5_binary_element (std::istream& if (! is.read (X_CAST (char *, name), len )) goto data_read_error; - is.seekg (pos + PAD (len)); + is.seekg (pos + static_cast (PAD (len))); } name[len] = '\0'; at @ -2682,7 +2682,7 @@ read_mat5_binary_element (std::istream& goto data_read_error; } - is.seekg (pos + PAD (len)); + is.seekg (pos + static_cast (PAD (len))); } // imaginary data subelement at @ -2720,7 +2720,7 @@ read_mat5_binary_element (std::istream& tc = tc.convert_to_str (); } - is.seekg (pos + element_length); + is.seekg (pos + static_cast (element_length)); return name; at @ -2734,7 +2734,7 @@ read_mat5_binary_element (std::istream& skip_ahead: warning (" skipping over `%s'", name); delete [] name; - is.seekg (pos + element_length); + is.seekg (pos + static_cast (element_length)); return read_mat5_binary_element (is, filename, swap, global, tc); } Index: src/DLD-FUNCTIONS/det.cc =================================================================== RCS file: /cvs/octave/src/DLD-FUNCTIONS/det.cc,v retrieving revision 1.5 diff -u -3 -p -r1.5 det.cc --- src/DLD-FUNCTIONS/det.cc 2001/03/27 19:12:59 1.5 +++ src/DLD-FUNCTIONS/det.cc 2001/04/09 16:00:14 at @ -104,7 +104,7 @@ of the reciprocal condition number if re if (nargout > 1) retval(1) = rcond; - retval(0) = (info == -1 ? 0.0 : det.value ()); + retval(0) = (info == -1 ? Complex(0.0) : det.value ()); } } else Regards, Mumit