—Are you going to suggest memset_s()?
—I don't know, it's only 2016, perhaps volatile…
cc @BRIAN_____
@johnregehr @spun_off AFAICT, the compiler is allowed to recognize when the pointed-at thing isn't actually volatile. That makes me nervous.
-
-
@BRIAN_____ When lv is volatile in “lv = …;”, it means that the write is an observable side-effect and must happen in correct order wrt … -
@BRIAN_____ other observable side-effects. It does not matter one bit that lv is “*(volatile t) &nonvol_var”. Must still happen. -
@BRIAN_____ We could get philosophical about what the address of an automatic variable is, but that's orthogonal to “volatile” really. -
@spun_off
@BRIAN_____ C/C++ have wonderful "as if" rule: can optimize proven you can't tell the difference without relying on UB. -
@jfbastien I don't know what clause of the C11 standard you are referring to, and regardless this is a terrible explanation. -
@jfbastien If the standard said that something were observable behavior, such an as-if rule would mean that it has to be preserved. -
@spun_off C++14 standard 1.9 Program execution [intro.execution] ¶1. Also see note 5 on that page.
-
@spun_off you can't rely on undefined behavior to exercise behavior. If the compiler proves that it's unobservable w/o UB then it can as-if.
- 5 more replies
New conversation -
-
-
@johnregehr @spun_off In particular, given: int x = 1; int volatile *p = &x; Couldn't (shouldn't?) the compiler just ignore the "volatile"? -
@BRIAN_____@johnregehr @spun_off Even if it shouldn't, sometimes it does: http://goo.gl/LDfPHG -
@sevenps@BRIAN_____ @spun_off I'll just leave this here and run away http://goo.gl/aJERCS -
@BRIAN_____ Sorry that it's so redundant but have you seen https://github.com/regehr/ub-canaries/issues/5 … ? -
@BRIAN_____ https://github.com/regehr/ub-canaries/issues/5#issuecomment-175182921 … makes a good point: if the array is in memory & gets overwritten there's already no guarantee about regs -
@spun_off Literally would be easier for me to code asm implementations for every platform I care about than to keep thinking about this. :)
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.