With this code
enum EnumTypes
{
one,
two
};
int enum_to_int(EnumTypes enum_type)
{
switch(enum_type)
{
case one: return 1;
case two: return 2;
}
}
I get the following warning:
: In function 'int enum_to_int(EnumTypes)': :14:1: warning: control reaches end of non-void function [-Wreturn-type] 14 | }
, which I understand is a valid warning since enum_type could have some other value stored than one and two.
However, if I mark the method as inline as the following, the warning disappears.
enum EnumTypes
{
one,
two
};
inline int enum_to_int(EnumTypes enum_type)
{
switch(enum_type)
{
case one: return 1;
case two: return 2;
}
}
Should there not be a warning if function is marked inline?
- Link without inline: https://godbolt.org/z/jcscchEGh
- Link with inline: https://godbolt.org/z/6qfeWeYsd