This could just return 1. $ cat unsigned-arith.c int foo(unsigned int *a, unsigned int *b, unsigned int *c) { unsigned int s1, s2;
s1 = *a + *b; s2 = *c + *b; return s1 + *c == s2 + *a; } $ gcc -O3 -S unsigned-arith.c $ cat unsigned-arith.s .file "unsigned-arith.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax pushl %ebx movl (%eax), %ecx movl 12(%ebp), %eax movl (%eax), %ebx movl 16(%ebp), %eax movl (%eax), %eax leal (%ebx,%eax), %edx leal (%ecx,%edx), %edx addl %ebx, %ecx popl %ebx addl %ecx, %eax cmpl %eax, %edx popl %ebp sete %al movzbl %al, %eax ret .size foo, .-foo .ident "GCC: (GNU) 4.1.0 20050815 (experimental)" .section .note.GNU-stack,"",@progbits $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.1/configure --prefix=/home/ig25 --enable-languages=c,f95 Thread model: posix gcc version 4.1.0 20050815 (experimental) -- Summary: Operations involving unsigneds could be simplified Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23429