Similar to other "if constexpr" related warnings, gcc warns on this example: void g(); void h(); template <bool B> void f() { if constexpr (B) { goto label; } g(); label: h(); } int main() { f<false>(); } <source>:12:1: warning: label 'label' defined but not used [-Wunused-label] 12 | label: | ^~~~~ But the label is used, just not in this particular instantiation.
Confirmed.
MSVC warns too: <source>(12): warning C4102: 'label': unreferenced label <source>(17): note: see reference to function template instantiation 'void f<false>(void)' being compiled clang does not though. I think GCC should not warn either.