https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113582
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> --- The reason I'm not doing simply TREE_USED (label) = TREE_USED (decl); in the pt.cc/LABEL_EXPR hunk is that I think we still want the warning in the second function, what with the goto being a discarded statement. // PR c++/113582 template<bool B> void do_something () { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-label" start: if constexpr(B) goto start; #pragma GCC diagnostic pop } template<bool B> void do_something2 () { start: // { dg-warning "defined but not used" } if constexpr(B) goto start; } void g () { do_something<0>(); do_something2<0>(); }