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

            Bug ID: 107797
           Summary: "warning right operand of comma operator has no
                    effect" for expressions with no comma operator
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

int main() {
    (long)new int{};
    long(new int{});
}

With -Wall this gives:

comma.cc: In function ‘int main()’:
comma.cc:2:20: warning: right operand of comma operator has no effect
[-Wunused-value]
    2 |     (long)new int{};
      |                    ^
comma.cc:3:20: warning: right operand of comma operator has no effect
[-Wunused-value]
    3 |     long(new int{});
      |                    ^


There is no comma operator in the code.

The bogus warning has been there since at least 6.1

Reply via email to