本文共 791 字,大约阅读时间需要 2 分钟。
If switch case if cannot cover all cases, then the return value is undefined.
Even though orientation
is an enum with only two values (right now), it can still have a different value for any of the following reasons:
side
might be uninitialized, so it could be neither left
nor right
side
might have been assigned another value via typecasting, e.g. *((int*)&side) = 2
Possible solutions include:
if
with an else
as suggested by sth.Change it to be:
if(side == left) { return ...;} else if(side == right) { return ...;} else { ...handle error...}
转载地址:http://stiqb.baihongyu.com/