From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10970 invoked by alias); 11 Feb 2003 10:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10923 invoked by uid 71); 11 Feb 2003 10:26:00 -0000 Resent-Date: 11 Feb 2003 10:26:00 -0000 Resent-Message-ID: <20030211102600.10922.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, snyder@fnal.gov Received: (qmail 10542 invoked from network); 11 Feb 2003 10:23:15 -0000 Received: from unknown (HELO d0mino.fnal.gov) (131.225.224.45) by 172.16.49.205 with SMTP; 11 Feb 2003 10:23:15 -0000 Received: from localhost (snyder@localhost) by d0mino.fnal.gov (SGI-8.9.3/8.9.3) with SMTP id EAA24256 for ; Tue, 11 Feb 2003 04:23:13 -0600 (CST) Message-Id: <200302111023.EAA24256@d0mino.fnal.gov> Date: Tue, 11 Feb 2003 10:26:00 -0000 From: snyder@fnal.gov Reply-To: snyder@fnal.gov To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: libstdc++/9659: 3.3/3.4 seekoff overload problem with optimization X-SW-Source: 2003-02/txt/msg00485.txt.bz2 List-Id: >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: >Environment: System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown Architecture: i686 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]': /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]' /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]' /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]' 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*) /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] 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 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: