This is the mail archive of the gcc-help@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]

Question about a warning message


Hello,

I'm getting a "control reaches end of non-void function" warning
message on the following code (tested with gcc version 7.3 and above):

enum class T { A, B };

int f(T t) {
   switch (t) {
   case T::A: return 10;
   case T::B: return 20;
   }
}

https://godbolt.org/z/IXC4Ff

Shouldn't the compiler assume that function `f` always returns
something for all valid inputs `t`? (Given that the parameter `t` is
of type `T` which is an enum class and the siwtch statement covers all
the enum values).

Regards,
Juan.


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