Emulating GCC's __builtin_unreachable?

前端 未结 5 1872
春和景丽
春和景丽 2020-12-24 13:18

I get a whole lot of warnings about switches that only partially covers the range of an enumeration switched over. Therefor, I would like to have a \"default\" for

5条回答
  •  被撕碎了的回忆
    2020-12-24 13:38

    Would abort (leaving a core dump) or throw (allowing for alternate data capture) accommodate your needs?

    Do you really want to have switch statements that don't cover the full enumeration? I nearly always try to list all the possible cases (to no-op) with no default case so that gcc will warn me if new enumerations are added, as it may be required to handle them rather than letting it silently (during compile) fall into the default.

提交回复
热议问题