[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] small tweaks for ISO C++ compliance, Sun C++ bug
From: |
Mumit Khan |
Subject: |
[patch] small tweaks for ISO C++ compliance, Sun C++ bug |
Date: |
Mon, 9 Apr 2001 13:19:13 -0500 (CDT) |
Two simple tweaks
- ISO C++ does not require an operator+ for streampos or fpos<charT> and
an integral type [ See 27.4.3.2/1 for fpos<charT> requirements ]. The
following testcase shows what the problem is:
#include <ios>
void
foo()
{
std::streampos pos;
long foo1;
int foo2; // FOUR_BYTE_INT
pos + foo1; // OK
pos + foo2; // not OK, ambiguous
pos + static_cast<std::streamoff> (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 <address@hidden>
* 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
@@ -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<std::streamoff> (dimension_length));
}
// array name subelement
@@ -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<std::streamoff> (PAD (len)));
}
name[len] = '\0';
@@ -2682,7 +2682,7 @@ read_mat5_binary_element (std::istream&
goto data_read_error;
}
- is.seekg (pos + PAD (len));
+ is.seekg (pos + static_cast<std::streamoff> (PAD (len)));
}
// imaginary data subelement
@@ -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<std::streamoff> (element_length));
return name;
@@ -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<std::streamoff> (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
@@ -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
- [patch] small tweaks for ISO C++ compliance, Sun C++ bug,
Mumit Khan <=