gcc/testsuite/c-c++-common/pr95903.c
raw| 1 | /* PR middle-end/95903 */ |
| 2 | /* { dg-do compile { target lp64 } } */ |
| 3 | /* { dg-options "-O2 -fwrapv -fdump-tree-optimized" } */ |
| 4 | /* Verify that for -fwrapv the + 1 addition is performed in the parameter's |
| 5 | type before sign extending it. */ |
| 6 | /* { dg-final { scan-tree-dump-times "off_\[0-9]+\\\(D\\\) \\+ 1" 2 "optimized" } } */ |
| 7 | |
| 8 | char |
| 9 | foo (const char *ptr, int off) |
| 10 | { |
| 11 | off += 1; |
| 12 | return ptr[off]; |
| 13 | } |
| 14 | |
| 15 | char |
| 16 | bar (const char *ptr, int off) |
| 17 | { |
| 18 | return ptr[off + 1]; |
| 19 | } |