Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


Hi,

Consider:

enum t {a, b};

OUString f(t i)
{
  switch(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
warning-turned-error?

I tried adding "assert(false)", which solves the warning on my
machine, but not on Jenkins build linux_gcc_release_64, cf
https://ci.libreoffice.org/job/lo_gerrit/15859/Config=linux_gcc_release_64/

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
https://gerrit.libreoffice.org/40567

Thanks for you advice,

Lionel

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.