opt_07_pointer_difference_index.c (580B)
1 /* A same-width pointer-to-ptrdiff conversion may become a physical copy after 2 * allocation. Copy propagation may change the index register, but the 3 * indirect use must retain its integer interpretation. */ 4 __attribute__((noinline)) static const char* pick(const char* base, 5 const char* tail, 6 char* copy) { 7 return &base[tail - copy]; 8 } 9 10 int test_main(void) { 11 char base[] = "0123456789"; 12 char copy[] = "abcdefghij"; 13 return *pick(base, copy + 4, copy) == '4' ? 42 : 1; 14 }