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

--- Comment #1 from Sean Murthy <s.murthy at outlook dot com> ---
I ran into this misleading warning message in *GCC 15.2*, but in a slightly
different way. For the following program, -Wunused-value warns that variables a
and c are unused, when in fact a and b are unused. The program itself correctly
returns c. Only the warning message is incorrect.

CE: https://sigcpp.godbolt.org/z/T5aW9Ec8h

PS: It looks like the original error reported existed until GCC 8.5. The error
(message) seems to have morphed to the following from GCC 9.1.

int main()
{
    int a = 0, b = 5, c = 7;
    return a, b, c;
}

<source>:4:12: warning: left operand of comma operator has no effect
[-Wunused-value]
    4 |     return a, b, c;
      |            ^
<source>:4:18: warning: right operand of comma operator has no effect
[-Wunused-value]
    4 |     return a, b, c;
      |                  ^

Reply via email to