[Bug c/59871] New: No unused value warning for comma expression

chengniansun at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jan 18 07:57:00 GMT 2014


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

            Bug ID: 59871
           Summary: No unused value warning for comma expression
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

I have a return statement with a comma expression -- "return  fn2(), 1, 0;".
Gcc should warn that the "1" in the middle is not used as it does not have any
side effect.  

The following is the detailed instructions to reproduce the issue. 

$: cat s.c
extern int fn2();
int fn1() {
  return  fn2(), 1, 0;
}
$: gcc-trunk -Wall -Wextra -c -std=c99 -pedantic s.c
$: gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/chengniansun/tools/gcc-trunk-binaries/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/home/chengniansun/tools/gcc-trunk-binaries
Thread model: posix
gcc version 4.9.0 20140109 (experimental) (GCC)
$: clang-trunk -Wall -Wextra -c -std=c99 -pedantic s.c
s.c:3:18: warning: expression result unused [-Wunused-value]
  return  fn2(), 1, 0;
                 ^
1 warning generated.



More information about the Gcc-bugs mailing list