This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/9659: 3.3/3.4 seekoff overload problem with optimization
- From: snyder at fnal dot gov
- To: gcc-gnats at gcc dot gnu dot org
- Date: Tue, 11 Feb 2003 04:23:13 CST
- Subject: libstdc++/9659: 3.3/3.4 seekoff overload problem with optimization
- Reply-to: snyder at fnal dot gov
>Number: 9659
>Category: libstdc++
>Synopsis: 3.3/3.4 seekoff overload problem with optimization
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Feb 11 10:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: scott snyder
>Release: 3.4 20030210 (experimental)
>Organization:
<organization of PR author (multiple lines)>
>Environment:
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
Architecture: i686
<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long
>Description:
When the source below is compiled with -O3, i get the following errors:
$ g++ -c -O3 x.cc
/usr/local/gcc/include/c++/3.4/bits/fstream.tcc: In member function `typename
std::basic_filebuf<_CharT, _Traits>::pos_type std::basic_filebuf<_CharT,
_Traits>::seekoff(typename _Traits::off_type, std::_Ios_Seekdir,
std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]':
/usr/local/gcc/include/c++/3.4/bits/fstream.tcc:104: instantiated from `typename std::basic_filebuf<_CharT, _Traits>::__filebuf_type* std::basic_filebuf<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]'
/usr/local/gcc/include/c++/3.4/fstream:564: instantiated from `void std::basic_ifstream<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]'
/usr/local/gcc/include/c++/3.4/fstream:520: instantiated from `std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]'
x.cc:9: instantiated from here
/usr/local/gcc/include/c++/3.4/bits/fstream.tcc:460: error: ambiguous overload
for `std::streampos& + char* const&' operator
/usr/local/gcc/include/c++/3.4/bits/fstream.tcc:460: error: candidates are:
operator+(int, char*) <built-in>
/usr/local/gcc/include/c++/3.4/bits/fpos.h:90: error:
std::fpos<_StateT> std::fpos<_StateT>::operator+(long int) [with _StateT =
mbstate_t] <near match>
x.cc:6: error: TString operator+(long int, const TString&)
$
It's a bit strange, because if -O2 or below is used, the error goes away.
Is the built-in operator mentioned in the error message visible only
if -O3 is used?
I see this problem both with 3.3 and 3.4.
It seems to be related to the patch for libstdc++/9439 and
libstdc++/9425 that was introduced recently. In fact,
if i rewrite the part of that patch where this error
is occuring to use += rather than +:
Index: fstream.tcc
===================================================================
RCS file: /cvsroot/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.47
diff -u -p -c -r1.47 fstream.tcc
*** fstream.tcc 4 Feb 2003 22:42:32 -0000 1.47
--- fstream.tcc 11 Feb 2003 09:54:38 -0000
*************** namespace std
*** 455,464 ****
{
pos_type __tmp =
_M_file.seekoff(__off, ios_base::cur, __mode);
! if (__tmp >= 0)
// Seek successful.
! __ret = __tmp +
! std::max(this->_M_out_cur, this->_M_in_cur) - _M_filepos;
}
}
_M_last_overflowed = false;
--- 455,465 ----
{
pos_type __tmp =
_M_file.seekoff(__off, ios_base::cur, __mode);
! if (__tmp >= 0) {
// Seek successful.
! __ret = __tmp;
! __ret += std::max(this->_M_out_cur, this->_M_in_cur) - _M_filepos;
! }
}
}
_M_last_overflowed = false;
then the error goes away.
>How-To-Repeat:
Compile with -O3:
----------------------
#include <fstream>
struct TString {
TString(const char *s);
};
TString operator+(long i, const TString& s);
void is_new(const char* f) {
std::ifstream test(f,std::ios::in);
}
----------------------
>Fix:
See above.
>Release-Note:
>Audit-Trail:
>Unformatted: