[Bug c/60103] New: Spurious -Wsequence-point warning with -O1

chengniansun at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 6 23:41:00 GMT 2014


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

            Bug ID: 60103
           Summary: Spurious -Wsequence-point warning with -O1
           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

Gcc -O1 emits an undefined behavior warning, whereas gcc -O0 not. 

Based on my understanding of the standard, I cannot see why it is an undefined
behavior. 

$: cat s.c
extern unsigned short fn2(unsigned short, unsigned short);
void fn1(int l) {
  l = fn2(l = 0, 0) || 0;
}
$: gcc-trunk -c -Wsequence-point -O1 s.c
s.c: In function ‘fn1’:
s.c:3:5: warning: operation on ‘l’ may be undefined [-Wsequence-point]
   l = fn2(l = 0, 0) || 0;
     ^
$: gcc-trunk -c -Wsequence-point -O0 s.c


More information about the Gcc-bugs mailing list