3 ms·
Not sure how you can say that. int a[4]; a[2]=2; a[6]=3; "Ignore the situation": emit the code the code for a[6]=3; in the same way you emitted the
by mpweiher 5y ago
Not sure how you can say that.
int a[4];
a[2]=2;
a[6]=3;
"Ignore the situation": emit the code the code for a[6]=3; in the same way you emitted the code for a[2]=2. You've ignored the fact that this is UB.
"Assume the situation cannot occur": don't know, but according to the UB extremists the compiler can now do anything it wants to do, including not emitting any code for this fragment at all (which appears to happen) or formatting your hard disk (which doesn't, last I checked).
Assuming that a[6]=3 does not occur, despite the fact that it is written right there, would also allow putting a into registers, which "ignoring the situation" would not.
- SAI_Peregrinus 5y agoTo me, the "situation" is that `a[6]` is being assigned to. So I'd make the compiler ignore the situation, and omit line 3. Then the compiler could optimize the remaining program, possibly by putting `a` into registers. I think you have a different view on what the "situation" is, so that your view of ignoring it is different from mine (and CRConrads, etc).