From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18987 invoked by alias); 24 Mar 2005 16:27:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 18809 invoked by uid 48); 24 Mar 2005 16:27:42 -0000 Date: Thu, 24 Mar 2005 16:27:00 -0000 From: "oliverst at online dot de" To: gcc-bugs@gcc.gnu.org Message-ID: <20050324162738.20624.oliverst@online.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/20624] New: wrong "control reaches end of non-void function" warning X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg02870.txt.bz2 List-Id: If you compile this code #include void test() { std::ifstream in; } against the actual CVS version of STLport 5.0 (http://www.breaken.de/temp/STLport.zip) you get this warning: In member function 'typename stlp_std::basic_filebuf<_CharT, _Traits>::pos_type stlp_std::basic_filebuf<_CharT, _Traits>::seekoff(typename _Traits::off_type, int, int) [with _CharT = char, _Traits = stlp_std::char_traits]': 372 C:\cvs\STLport\stlport\stl\_fstream.c [Warning] control reaches end of non-void function Because the STLport is very complex I wasn't able to reduce the code properly. Maybe it can already be done by just posting the function causing it: template __BF_pos_type__ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __whence, ios_base::openmode /* dummy */) { if (this->is_open() && (__off == 0 || (_M_constant_width && this->_M_base._M_in_binary_mode()))) { if (!_M_seek_init(__off != 0 || __whence != ios_base::cur)) return pos_type(-1); // Seek to beginning or end, regardless of whether we're in input mode. if (__whence == ios_base::beg || __whence == ios_base::end) return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence), _State_type()); // Seek relative to current position. Complicated if we're in input mode. else if (__whence == ios_base::cur) { if (!_M_in_input_mode) return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence), _State_type()); else if (_M_mmap_base != 0) { // __off is relative to gptr(). We need to do a bit of arithmetic // to get an offset relative to the external file pointer. streamoff __adjust = _M_mmap_len - (this->gptr() - (_CharT*) _M_mmap_base); // if __off == 0, we do not need to exit input mode and to shift file pointer if (__off == 0) { return pos_type(_M_base._M_seek(0, ios_base::cur) - __adjust); } else return _M_seek_return(_M_base._M_seek(__off - __adjust, ios_base::cur), _State_type()); } else if (_M_constant_width) { // Get or set the position. streamoff __iadj = _M_width * (this->gptr() - this->eback()); // Compensate for offset relative to gptr versus offset relative // to external pointer. For a text-oriented stream, where the // compensation is more than just pointer arithmetic, we may get // but not set the current position. if (__iadj <= _M_ext_buf_end - _M_ext_buf) { streamoff __eadj = _M_base._M_get_offset(_M_ext_buf + __iadj, _M_ext_buf_end); if (__off == 0) { return pos_type(_M_base._M_seek(0, ios_base::cur) - __eadj); } else { return _M_seek_return(_M_base._M_seek(__off - __eadj, ios_base::cur), _State_type()); } } else return pos_type(-1); } else { // Get the position. Encoding is var width. // Get position in internal buffer. ptrdiff_t __ipos = this->gptr() - this->eback(); // Get corresponding position in external buffer. _State_type __state = _M_state; int __epos = _M_codecvt->length(__state, _M_ext_buf, _M_ext_buf_end, __ipos); // Sanity check (expensive): make sure __epos is the right answer. _State_type __tmp_state = _M_state; _Filebuf_Tmp_Buf<_CharT> __buf(__ipos); _CharT* __ibegin = __buf._M_ptr; _CharT* __inext = __ibegin; const char* __dummy; typename _Codecvt::result __status = _M_codecvt->in(__tmp_state, _M_ext_buf, _M_ext_buf + __epos, __dummy, __ibegin, __ibegin + __ipos, __inext); if (__status != _Codecvt::error && (__status == _Codecvt::noconv || (__inext == __ibegin + __ipos && equal(this->gptr(), this->eback(), __ibegin, _Eq_traits())))) { // Get the current position (at the end of the external buffer), // then adjust it. Again, it might be a text-oriented stream. streamoff __cur = _M_base._M_seek(0, ios_base::cur); streamoff __adj = _M_base._M_get_offset(_M_ext_buf, _M_ext_buf + __epos) - _M_base._M_get_offset(_M_ext_buf, _M_ext_buf_end); if (__cur != -1 && __cur + __adj >= 0) return _M_seek_return(__cur + __adj, __state); else return pos_type(-1); } else // We failed the sanity check. return pos_type(-1); } } else // Unrecognized value for __whence. return pos_type(-1); } else return pos_type(-1); } I also got another piece of code, that also causes a wrong warning, but I wasn't able to reduce that code either. I am using Target: i686-pc-mingw32 Configured with: /datal/gcc/gcc/configure --prefix=/datal/gcc/build/wingcc --build=i686-pc-linux-gnu --host=i686-pc-mingw32 --target=i686-pc-mingw32 --enable-languages=c,c++,java --with-gcc --with-gnu-as --with-gnu-ld --enable-threads=win32 --disable-nls --disable-win32-registry --disable-shared --disable-debug --without-newlib --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-sjlj-exceptions --enable-libgcj-multifile --enable-libgcj-mingw-osapi=ansi Thread model: win32 gcc version 4.0.0 20050320 (prerelease) -- Summary: wrong "control reaches end of non-void function" warning Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: oliverst at online dot de CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20624