Stream: t-compiler/wg-mir-opt

Topic: zst read/write from/to dangling pointer


oli (Dec 23 2019 at 10:54, on Zulip):

I thought writes of zsts to dangling pointers is fine?

Not always, no. If the pointer is a Pointer (not an integer), but dangling (out-of-bounds or use-after-free), it's UB even with ZST. Also see this test.

That seems very fragile. I can totally see wg-mir-opt creating an optimization pass that just removes all reads and writes to/from zsts from the MIR

oli (Dec 23 2019 at 10:55, on Zulip):

then that test would suddenly run successfully

oli (Dec 23 2019 at 10:55, on Zulip):

Ok, technically we'd still need an alignment check left over

oli (Dec 23 2019 at 10:56, on Zulip):

hmm ok, if this is UB, then we're allowed to optimize it

oli (Dec 23 2019 at 10:56, on Zulip):

so the optimization would still be sound

RalfJ (Dec 23 2019 at 11:37, on Zulip):

That seems very fragile. I can totally see wg-mir-opt creating an optimization pass that just removes all reads and writes to/from zsts from the MIR

it's okay for opzimizations to remove UB

RalfJ (Dec 23 2019 at 11:37, on Zulip):

what you said

RalfJ (Dec 23 2019 at 11:38, on Zulip):

so, yeah, reliable UB-testing requires disabling all optimizations. no surprise there.

Last update: Apr 05 2020 at 00:35UTC