Package: g++-4.0
Version: 4.0.1-2
compiling with '-Wall' gives in some cases the warning 'control reaches end of non-void function' for code of the following form
if (a)
return 10;
else
return 20;
at the end of a function. The 3.3er version of g++ does not give the warning.
At the end is an example to test. Further removing of code makes the warning disappear although it should have nothing to do with it.
-- versions
$ g++-4.0 -c -Wall end_of_non-void_function.cpp
end_of_non-void_function.cpp: In member function 'Hand Player::handofplayer(const Player&) const':
end_of_non-void_function.cpp:67: warning: control reaches end of non-void function
$ g++-4.0 -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.1 (Debian 4.0.1-2)
$ dpkg -l g++-4.0
ii g++-4.0 4.0.1-2 The GNU C++ compiler
$ g++-3.3 -Wall -c end_of_non.cpp
$
$ g++-3.3 -v
Lese Spezifikationen von /usr/lib/gcc-lib/i486-linux/3.3.5/specs
Konfiguriert mit: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread-Modell: posix
gcc-Version 3.3.5 (Debian 1:3.3.5-13)
$ dpkg -l g++-3.3
ii g++-3.3 3.3.5-13 The GNU C++ compiler
The other packages are of the testing version but the kernel, which is 2.6.12.3 (from www.kernel.org), self compiled.
-- example file (compile with 'g++-4.0 -c -Wall')
class Player;
class Hand {
public:
Hand(Player const& player);
~Hand();
};
class Player {
public:
Hand const& hand() const;
Hand handofplayer(Player const& player) const;
};
Hand
Player::handofplayer( Player const& player ) const
{
if (false)
return this->hand();
// Ai, Player, Hand are self defined classes
Hand hand(player);
extern const bool INFO_AI;
extern const bool INFO_OTHER_FUNCTION;
if (INFO_AI && INFO_OTHER_FUNCTION)
return hand;
else
return hand;
}
Attachment:
signature.asc
Description: Digital signature