This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
various tweaks
- To: libstdc++@sourceware.cygnus.com
- Subject: various tweaks
- From: Michael Cook <cook@sightpath.com>
- Date: 02 Aug 1999 11:11:57 -0400
Here are some changes I needed to make to the bits/*.h headers to
get my code to compile cleanly.
I'm not necessarily proposing that any of these changes be committed
into cvs. I just wanted to let people know what kinds of problems I
encountered in case they are new.
I compiled my code with these gcc warnings enabled:
-Wall -W -Woverloaded-virtual -Werror -Wwrite-strings
Briefly:
- There seem to be some missing #include directives here and
there.
- The static function __get_c_string evokes a warning from gcc
in the situations where the function ends up not being invoked.
- There are some unused variables here and there, some
"misordered initializers", and one function that should return a
value but doesn't.
- Gcc complains about comparing signed and unsigned values in a few
places.
- The most significant (least superficial) problem seems to be a
mixing of pointers and iterators.
(I'm using gcc-2.95.)
--- basic_string.h.DIST Sun Aug 1 19:57:16 1999
+++ basic_string.h Sun Aug 1 22:03:42 1999
@@ -910,8 +910,12 @@
basic_string<_CharT, _Traits, _Alloc>& __str);
// for SGI exception classes
+#if 0
static const char*
__get_c_string(const string& __s) { return __s.c_str(); }
+#else
+ #define __get_c_string(__s) __s.c_str()
+#endif
} // namespace std
--- fstream.tcc.DIST Sun Aug 1 20:39:36 1999
+++ fstream.tcc Sun Aug 1 20:44:02 1999
@@ -40,8 +40,8 @@
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
basic_filebuf()
- : __streambuf_type(), _M_state_cur(), _M_state_beg(), _M_buf(NULL),
- _M_last_overflowed(false)
+ : __streambuf_type(), _M_buf(NULL), _M_last_overflowed(false),
+ _M_state_cur(), _M_state_beg()
{
_M_buf_unified = true; // Tie input to output for basic_streambuf.
_M_fcvt = &use_facet<__codecvt_type>(this->getloc());
@@ -453,7 +453,7 @@
xsputn(const char_type* __s, streamsize __n)
{
bool __testinit = _M_is_indeterminate();
- bool __testinout = _M_mode & ios_base::in && _M_mode & ios_base::out;
+ //bool __testinout = _M_mode & ios_base::in && _M_mode & ios_base::out;
bool __testin = _M_mode & ios_base::in;
streamsize __retval = 0;
@@ -489,7 +489,7 @@
void
basic_filebuf<_CharT, _Traits>::_M_output_unshift()
{
- int __width = _M_fcvt->encoding();
+ //int __width = _M_fcvt->encoding();
// XXX Not complete, or correct.
#if 0
--- std_fstream.h.DIST Mon Aug 2 01:04:48 1999
+++ std_fstream.h Mon Aug 2 01:04:48 1999
@@ -312,7 +312,7 @@
basic_ofstream(const char* __s,
ios_base::openmode __m = ios_base::out | ios_base::trunc)
: __ios_type(new __filebuf_type()), __ostream_type()
- { this->open(__s, __mode); }
+ { this->open(__s, __m); }
~basic_ofstream()
{
--- std_streambuf.h.DIST Sun Aug 1 19:57:18 1999
+++ std_streambuf.h Sun Aug 1 20:42:31 1999
@@ -245,18 +245,18 @@
virtual basic_streambuf<char_type,_Traits>*
setbuf(char_type*, streamsize)
{
- if (this->gptr() && this->gptr() != this->egptr())
+ //if (this->gptr() && this->gptr() != this->egptr())
return this;
}
virtual pos_type
seekoff(off_type, ios_base::seekdir,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
+ ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{ return pos_type(off_type(-1)); }
virtual pos_type
seekpos(pos_type,
- ios_base::openmode __mode = ios_base::in | ios_base::out)
+ ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{ return pos_type(off_type(-1)); }
virtual int
--- stl_algo.h.DIST Sun Aug 1 19:57:25 1999
+++ stl_algo.h Sun Aug 1 22:15:11 1999
@@ -32,6 +32,7 @@
#define __SGI_STL_INTERNAL_ALGO_H
#include <bits/stl_heap.h>
+#include <bits/stl_tempbuf.h>
__STL_BEGIN_NAMESPACE
--- stl_deque.h.DIST Sun Aug 1 19:57:25 1999
+++ stl_deque.h Sun Aug 1 23:36:05 1999
@@ -1090,7 +1090,8 @@
else {
difference_type __n = __last - __first;
difference_type __elems_before = __first - _M_start;
- if (__elems_before < (size() - __n) / 2) {
+ difference_type __nn = (size() - __n) / 2;
+ if (__elems_before < __nn) {
copy_backward(_M_start, __first, __last);
iterator __new_start = _M_start + __n;
destroy(_M_start, __new_start);
@@ -1448,7 +1449,8 @@
{
const difference_type __elemsbefore = __pos - _M_start;
size_type __length = size();
- if (__elemsbefore < __length / 2) {
+ const difference_type __nn = __length / 2;
+ if (__elemsbefore < __nn) {
iterator __new_start = _M_reserve_elements_at_front(__n);
iterator __old_start = _M_start;
__pos = _M_start + __elemsbefore;
--- stl_string_fwd.h.DIST Sun Aug 1 19:57:26 1999
+++ stl_string_fwd.h Sun Aug 1 22:02:18 1999
@@ -29,7 +29,9 @@
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
+#if 0
static const char* __get_c_string(const string&);
+#endif
__STL_END_NAMESPACE
--- stl_tempbuf.h.DIST Sun Aug 1 19:57:26 1999
+++ stl_tempbuf.h Sun Aug 1 22:23:50 1999
@@ -31,6 +31,9 @@
#ifndef __SGI_STL_INTERNAL_TEMPBUF_H
#define __SGI_STL_INTERNAL_TEMPBUF_H
+#include <bits/type_traits.h>
+#include <utility>
+
__STL_BEGIN_NAMESPACE
template <class _Tp>
--- stl_vector.h.DIST Sun Aug 1 19:57:26 1999
+++ stl_vector.h Mon Aug 2 01:39:12 1999
@@ -556,7 +556,7 @@
}
else if (size() >= __xlen) {
iterator __i(copy(__x.begin(), __x.end(), begin()));
- destroy(__i, _M_finish);
+ destroy(_M_start + (__i - begin()), _M_finish);
}
else {
copy(__x.begin(), __x.begin() + size(), _M_start);
@@ -761,7 +761,7 @@
size_type __n = 0;
distance(__first, __last, __n);
if (size_type(_M_end_of_storage - _M_finish) >= __n) {
- const size_type __elems_after = _M_finish - __position;
+ const size_type __elems_after = _M_finish - &*__position;
iterator __old_finish(_M_finish);
if (__elems_after > __n) {
uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
--- string.tcc.DIST Sun Aug 1 19:57:18 1999
+++ string.tcc Sun Aug 1 22:13:37 1999
@@ -40,6 +40,8 @@
#ifndef _CPP_BITS_STRING_TCC
#define _CPP_BITS_STRING_TCC 1
+#include <bits/stl_algo.h>
+
namespace std
{
M.