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

            Bug ID: 91391
           Summary: Bogus -Wcomma-subscript
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sbergman at redhat dot com
  Target Milestone: ---

With recent git master (4ad9380bafd772cea54392c7189cab07a2121fc9 here):

> $ cat test.cc
> #include <map>
> #include <utility>
> int main() {
>     std::map<std::pair<int, int>, int> m;
>     m[std::pair<int, int>(0, 0)] = 0;
> }

> $ g++ -fsyntax-only -std=c++2a test.cc
> test.cc: In function ‘int main()’:
> test.cc:5:20: warning: top-level comma expression in array subscript is 
> deprecated [-Wcomma-subscript]
>     5 |     m[std::pair<int, int>(0, 0)] = 0;
>       |                    ^

It should apparently not warn about the nested comma in the
template-parameter-list, and I wonder whether it should warn about a
(hypothetical) comma expression in a call to an overloaded operator [] at all.

Reply via email to