2 ms·
> Apologies, but "ignoring the situation completely with undpredictable results" is the exact opposite of "assuming the situation cannot occur and acting on tha
by CRConrad 5y ago
> Apologies, but "ignoring the situation completely with undpredictable results" is the exact opposite of "assuming the situation cannot occur and acting on that assumption".
Seems to me it's not the opposite but the exact same thing.
- mpweiher 5y agoNot 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).