4 ms·
In the section about the ambiguous provenance from synthesising pointers, it's explained that the compiler will infer the correct provenance from usage. Would i
by Measter 1y ago
In the section about the ambiguous provenance from synthesising pointers, it's explained that the compiler will infer the correct provenance from usage. Would it not be worth having some way for the programmer to inform the compiler directly, with something analogous to Rust's Strict Provenance ptr::with_addr?
To convert it to C syntax, it's a function with roughly this signature:
void* with_addr(void* ptr, uintptr_t addr)
Where the returned pointer has the address of `addr` and the provenance of `ptr`.
- uecker 1y agoThe proposal is mostly designed this way to make sure existing code is valid. One could add something "with_addr", but I am not convinced that it is really worth it.
- charleslmunger 1y agoThis is doable via this trick: https://github.com/protocolbuffers/protobuf/blob/ae0129fcd0128b411c968d9a21eb93a5d0253ddf/upb/wire/eps_copy_input_stream.h#L241 https://github.com/protocolbuffers/protobuf/blob/ae0129fcd01...
- cryptonector 1y agoI'd also like to have builtin functions and/or function attributes for designating allocation and deallocation. malloc() and free() (and realloc()) should not be special because of their names -- they should be special because of their declared attributes or their derived attributes given their internals.