c++ - control may reach end of non-void function xcode -
i have third party library code segment has following structure:
class a; func() { if(...) { return a(...); } else if(...) { return a(...); } else { log(...); } } and gives error "control may reach end of non-void function" in xcode.
the same segment compile in vs2012 without problem. xcode c++ compiler dialect , standard library set c++89 , libstdc++. know expected behaviour doesn't vs2012 compiler behave in accordance standards?
when writing like
type func() { ... } the compiler expect return object of type type in every paths of function, not here.
or log function return a object, doubt, , should write return log(), or log logging , should return a, null, throw exception or whatever need, don't reach end of function without returning anything.
i don't know why vs2012 compile whereas, imho, shouldn't if does, don't write code that, you'll surprises later on project.
Comments
Post a Comment