silencing warning "control reaches end of non-void function"

Lionel Elie Mamane lionel at
Sun Jul 30 17:26:02 UTC 2017



enum t {a, b};

OUString f(t i)
  case t::a;
    return "it was an a";
  case t::b;
    return "it was a b";

gcc -Werror fails with
error: control reaches end of non-void function [-Werror=return-type]

But that is not true; since all possible values are treated and
return, it cannot fall through. How do I silence that spurious

I tried adding "assert(false)", which solves the warning on my
machine, but not on Jenkins build linux_gcc_release_64, cf

I don't want to add a fake
 return "never reached";
because I want compilation to fail if/when the switch is not
exhaustive (e.g. change of definition of enum t).

The "f" above is FilterManager::getFilterComponent in file
connectivity/source/commontools/filtermanager.cxx of

Thanks for you advice,


More information about the LibreOffice mailing list