3 ms·
The bug is clearly the writing past the end of an array. That is: *(p+1) = 10; If you start with a buggy program, that it stays buggy after optimizations
by pierrebai 6y ago
The bug is clearly the writing past the end of an array. That is:
*(p+1) = 10;
If you start with a buggy program, that it stays buggy after optimizations is not surprising!
Edit: what;s more, the original form of the program also did not write through the q pointer and could have had optimizer the print zero. In the first form, the author assumes the compiler can track the pointer q through q == qi and avoid the optimization that would print zero, but fail to track pointer q through pi + 1 == qi == q.
- mskslal 6y agoNo, the original program writes through iq, which is well defined. Only the optimized program writes through p+1.