https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86733
--- Comment #2 from Emmanuel Thomé <Emmanuel.Thome at inria dot fr> --- (In reply to Jonathan Wakely from comment #1) > Presumably the handling for the pragma just turns the option on without > considering the current cxx_dialect. It seems to me that it is not consistent with the test case compiling fine with g++ -std=c++11 -c foo.cpp , is it ? > This should fix it: > > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > @@ -9210,7 +9210,7 @@ cp_parser_binary_expression (cp_parser* parser, bool > cast_p, > /* Get an operator token. */ > token = cp_lexer_peek_token (parser->lexer); > > - if (warn_cxx11_compat > + if (warn_cxx11_compat && cxx_dialect < cxx11 > && token->type == CPP_RSHIFT > && !parser->greater_than_is_operator_p) > { Yes it does. However, when reading gcc/c-family/c-opts.c one surmises that there is an intent to disable warn_cxx11_compat altogether if cxx_dialect >= cxx11 ; this code path is apparently not walked when warnings are enabled with #pragma, which (I presume) sets -Wall only based on EnabledBy and LangEnabledBy in c.opt, unconditionally. Maybe there are other bugs in the same vein, then (insofar as "warning X is enabled by -Wall [or -Wextra] in [dialect XYZ]" is often implemented in c-opts.c, and would then be missed by the #pragma).