Question about a warning message

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

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux