This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/19631] New: [4.0.0 regression] Strange warnings with -Wreturn-type


Current CVS g++ emits new (and probably wrong) warnings when compiling the code
below.

#include <sstream>
#include <string>

using namespace std;

string trim (const string &orig)
  {
  string::size_type p1=orig.find_first_not_of(" \t");
  if (p1==string::npos) return "";
  string::size_type p2=orig.find_last_not_of(" \t");
  return orig.substr(p1,p2-p1+1);
  }

string dataToString (const float &x)
  {
  ostringstream strstrm;
  strstrm << x;
  return trim(strstrm.str());
  }
string dataToString (const double &x)
  {
  ostringstream strstrm;
  strstrm << x;
  return trim(strstrm.str());
  }

martin@linuxamd64:~/tmp> g++ -v -Wreturn-type -c -O test.cc
Using built-in specs.
Configured with: /home/martin/software/gcc/configure --quiet
--prefix=/home/martin/software/ugcc --enable-languages=c++,f95 --disable-checking
Thread model: posix
gcc version 4.0.0 20050125 (experimental)
 /home/martin/software/ugcc/libexec/gcc/x86_64-unknown-linux-gnu/4.0.0/cc1plus
-quiet -v -D_GNU_SOURCE test.cc -quiet -dumpbase test.cc -mtune=k8 -auxbase test
-O-Wreturn-type -version -o /tmp/ccBnH5YM.s
ignoring nonexistent directory
"/home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0
 /home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0/x86_64-unknown-linux-gnu
 /home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0/backward
 /usr/local/include
 /home/martin/software/ugcc/include
 /home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/include
 /usr/include
End of search list.
GNU C++ version 4.0.0 20050125 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.0.0 20050125 (experimental).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128049
/home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0/bits/basic_string.tcc:
In static member function ?static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIterator, _InIterator, const _Alloc&,
std::forward_iterator_tag) [with _FwdIterator = char*, _CharT = char, _Traits =
std::char_traits<char>, _Alloc = std::allocator<char>]?:
/home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0/bits/basic_string.tcc:141:
warning: control may reach end of non-void function ?_CharT*
std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_refdata() [with _CharT =
char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]? being
inlined
/home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0/sstream:
In function ?std::string dataToString(const double&)?:
/home/martin/software/ugcc/lib/gcc/x86_64-unknown-linux-gnu/4.0.0/../../../../include/c++/4.0.0/sstream:478:
warning: control may reach end of non-void function ?std::basic_string<_CharT,
_Traits, _Alloc> std::basic_stringbuf<_CharT, _Traits, _Alloc>::str() const
[with _CharT = char, _Traits = std::char_traits<char>, _Alloc=
std::allocator<char>]? being inlined
 as -V -Qy -o test.o /tmp/ccBnH5YM.s
GNU assembler version 2.15.91.0.2 (x86_64-suse-linux) using BFD version
2.15.91.0.2 20040727 (SuSE Linux)


These warnings are not present with g++-3.3.4.

It is also interesting that the warnings are only generated when _both_
dataToString() functions are present; only one of them does not trigger the
error.
I'm working on a smaller testcase, but can't promise anything.
As far as I know the new behaviour must have been introduced in the last few days.

-- 
           Summary: [4.0.0 regression] Strange warnings with -Wreturn-type
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: martin at mpa-garching dot mpg dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19631


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]