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

            Bug ID: 59819
           Summary: -Wunused-value reports incorrect values as unused
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: caibbor at gmail dot com

Created attachment 31836
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31836&action=edit
The program in full to replicate this bug

This is pretty trivial but the warning outputs incorrect information. given the
line:

int foo = static_cast< int >( 1, 2, 3 );

G++ reports that value 2 and 3 are not used, when in fact 1 and 2 are not used.

G++ 4.8.1's output (with -Wall):
test.cpp: In function ‘int main()’:
test.cpp:15:35: warning: left operand of comma operator has no effect
[-Wunused-value]
  int foo = static_cast< int >( 1, 2, 3 );
                                   ^
test.cpp:15:38: warning: right operand of comma operator has no effect
[-Wunused-value]
  int foo = static_cast< int >( 1, 2, 3 );
                                      ^


Clang 3.2.7 gets it right, however:

test.cpp:15:32: warning: expression result unused [-Wunused-value]
        int foo = static_cast< int >( 1, 2, 3 );
                                      ^
test.cpp:15:35: warning: expression result unused [-Wunused-value]
        int foo = static_cast< int >( 1, 2, 3 );
                                         ^
2 warnings generated.

Reply via email to