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++/11474] New: -Wreturn-type should default to on when compiling C++


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: -Wreturn-type should default to on when compiling C++
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lloyd at randombit dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: i686-linux

This is pretty simple - when using C++, -Wreturn-type should a) always be on,
and b) always cause an error, since not returning correctly from the function
is ALWAYS an error in C++ (seems like it would be in C but I'm not a sufficient
C fiend to say for sure).

For example, the following source file:
-----------------------------
#include <iostream>
#include <ctime>

int foo()
   {
   if(std::time(0) % 2) return 5;
   }

int main()
   {
   std::cout << foo() << std::endl;
   return 0;
   }
-----------------------------

should probably fail to compile (or at least get a warning) regardless of the
flags enabled (unless -Wno-return-type is on, I guess).

Basically, for C++ -Wreturn-type should be turned on by default, and if
somebody wants to turn it off they can.


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