4 ms·
I can't replicate this example on my mac. Regardless of `diff` or 16 (which is the diff for me), I get the same output for clang and gcc: 7 5 7
by algesten 8y ago
I can't replicate this example on my mac. Regardless of `diff` or 16 (which is the diff for me), I get the same output for clang and gcc: 7 5 7
- micro-ram 8y agoAgreed. I get the intended result of 7 5 7 on macOS 10.13.6 LLVM. Mac:tmp $ clang -O3 mem1d.c ; ./a.out diff = -96 x = 0x7f9f4fc00300, *x = 7 y = 0x7f9f4fc00360, *y = 5 p = 0x7f9f4fc00300, *p = 7 Mac:tmp $ diff mem1d.c mem2d.c 13c13 < int *p = (int *)(yi + diff); --- > int *p = (int *)(yi - 96); Mac:tmp $ clang -O3 mem2d.c ; ./a.out diff = -96 x = 0x7fc2b5c00300, *x = 7 y = 0x7fc2b5c00360, *y = 5 p = 0x7fc2b5c00300, *p = 7 Mac:tmp$ clang --version Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix
- daveFNbuck 8y agoYou only pasted a clang run here. It's gcc that's supposed to give 3 5 7.
- daveFNbuck 8y agoI get a 16 diff too, but I'm seeing 3 5 7 on gcc on High Sierra with a 2013 Macbook Pro. I'm using gcc 8.2.0 installed via Homebrew. Did you run gcc-8 with the -O3 flag?