https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86733

            Bug ID: 86733
           Summary: c++17 and #pragma GCC diagnostic warning "-Wall"
                    resurrect pre-c++11 warnings.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Emmanuel.Thome at inria dot fr
  Target Milestone: ---

gcc 8.1.0 here.

The following simple code expectedly fails to compile with -std=c++98 because
of the double angle brackets. (g++ -std=c++98 -c /tmp/foo.cpp)

#pragma GCC diagnostic warning "-Wall"
template<int n> class foo { };
template<typename T> struct bar { struct type { }; };
template<int n> struct baz { typedef typename bar<foo<n>>::type type; };

With -std=c++11, this works fine, and no warning is triggered.

With -std=c++17, I get a warning that I had not expected.

localhost $ g++ -std=c++17 -c foo.cpp 
foo.cpp:4:56: warning: ‘>>’ operator is treated as two right angle brackets in
C++11 [-Wc++11-compat]
 template<int n> struct baz { typedef typename bar<foo<n>>::type type; };
                                                        ^~
foo.cpp:4:56: note: suggest parentheses around ‘>>’ expression


The #pragma plays a role here. The warning is triggered only when the #pragma
is enabled. I haven't been able to trigger it with the #pragma commented out
and a command-line flag (e.g. not with -std=c++17 -Wall, nor with -std=c++17
-Wc++11-compat).

Reply via email to