False positive warning: missing return statement and switch statements

John Love-Jensen eljay@adobe.com
Tue Nov 15 22:47:00 GMT 2005

Hi Frans,

> Obviously, I am looking at this the wrong way -- please explain.

Improve your code safety using C++ capabilities:

int toInt(const Number num)
  case Zero:
    return 0;
  case One:
    return 1;
  case Two:
    return 2;
    throw std::range_error("toInt(): enum Number out of range");

Then the warning goes away, and your code is better.


More information about the Gcc-help mailing list