On Monday, 15 June 2015 at 16:16:28 UTC, Steven Schveighoffer wrote:
How can the compiler POSSIBLY know whether a pointer points at GC data in order to make it undefined behavior?

It doesn't need to, the undefined behaviour comes from the unfulfilled expectations of the GC. For example, a "sufficiently advanced GC" with enough knowledge of types, including of local vars, could by chance run just at the moment when the only instance of the address is stored in an int variable, and disregard that variable because it's not a pointer. It is of course unlikely that GCs will ever get as much knowledge about local variables, or even unnamed temporaries...


I don't see any justification for any of these restrictions. The "to allow maximum flexibility" justification needs more explanation, what possible feature could you implement given this restriction?

It even allows using unions to do exactly the same thing. There is just no way this cannot be allowed.

For unions, an advanced GC would know the type and would make sure to treat them conservatively. The restrictions are for the other cases where the types are references. The GC needs to rely on them being pointer if it wants to move them, for example.

But I think you are right that the current restrictions are too strong. After some thoughts, I can't really see any realistic problem with tagged pointers.

Reply via email to