Tested x86_64-pc-linux-gnu, applying to trunk. Marek, I hope this change doesn't interfere with your work on P2865R5.
-- 8< -- P2865R5 pointed out that we only enabled this warning with -Wall; we should handle it like other deprecations. gcc/c-family/ChangeLog: * c-opts.cc (c_common_post_options): Enable -Warray-compare in C++20. gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/pr15791-1.C: Add -Wno-array-compare. --- gcc/c-family/c-opts.cc | 5 +++++ gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C | 1 + 2 files changed, 6 insertions(+) diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index fb9d0875b8e..8b143e78c07 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1052,6 +1052,11 @@ c_common_post_options (const char **pfilename) warn_deprecated_literal_operator, deprecated_in (cxx23)); + /* -Warray-compare is enabled by default in C++20. */ + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + warn_array_compare, + warn_array_compare || deprecated_in (cxx20)); + /* -Wtemplate-id-cdtor is enabled by default in C++20. */ SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_template_id_cdtor, diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C index 68f14adad00..9905851ee7c 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C @@ -1,4 +1,5 @@ /* { dg-do link } */ +/* { dg-additional-options -Wno-array-compare } */ void link_error (); base-commit: 819f67a2f633d2000f09119f0e19b784ea0a4bd8 -- 2.47.0