[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#119440: g++: Compiler does not give any errors when a function fails to return required value



Package: g++
Version: 2:2.95.4-8
Severity: normal

In a member function such as:
int Partition::in_which_part()
{
  int i;
  ....
}

A return statement with type of int is required. However, the compiler
fails to give any error/warning when the corresponding return statement
is omitted, when invoked with default options.

In the current case, the compiler does not even give a warning message
by default. Giving an error message might break valid C++ code (which
I'm not sure of) but it seems that when you specify -Wall the compiler
will detect whether
src/generic/Utility.hxx:173: warning: control reaches end of non-void function `Utility::operator <<<int, less<int> >(ostream &, const set<int,less<int>,allocator<int> > &)'

I think this should be the default behavior, which may be suppressed
with a flag if desired.

Thanks,

-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux orion 2.4.7 #1 Tue Jul 31 12:20:28 EEST 2001 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages g++ depends on:
ii  cpp                    2:2.95.4-8        The GNU C preprocessor.
ii  g++-2.95               1:2.95.4-0.011006 The GNU C++ compiler.
ii  gcc-2.95               1:2.95.4-0.011006 The GNU C compiler.




Reply to: