about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-05-24 15:58:26 +0200
committerGitHub <noreply@github.com>2022-05-24 15:58:26 +0200
commit4bd40186dbb498f8a3952a24f343b468ad5ef064 (patch)
tree27999aee32cdff30d1658addd4eac9ffd9f935e0 /compiler/rustc_codegen_gcc
parentaf15e45e283640ec72642949511abf113a7a6c57 (diff)
parent5137d15f91d5778a0d037e5bc4f1f70d9b013aa7 (diff)
downloadrust-4bd40186dbb498f8a3952a24f343b468ad5ef064.tar.gz
rust-4bd40186dbb498f8a3952a24f343b468ad5ef064.zip
Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC
explain how to turn integers into fn ptrs

(with an intermediate raw ptr, not a direct transmute)
Direct int2ptr transmute, under the semantics I am imagining, will produce a ptr with "invalid" provenance that is invalid to deref or call. We cannot give it the same semantics as int2ptr casts since those do [something complicated](https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html).

To my great surprise, that is already what the example in the `transmute` docs does. :)  I still added a comment to say that that part is important, and I added a section explicitly talking about this to the `fn()` type docs.

With https://github.com/rust-lang/miri/pull/2151, Miri will start complaining about direct int-to-fnptr transmutes (in the sense that it is UB to call the resulting pointer).
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions