upvote
Finding unsoundness bugs isn't the most unusual, yes. But this one is unusual in how simple the code that causes it can be (see the versions of the reproducer code in the comments). For other unsoundness bugs, the code would need to contort itself a lot to avoid the compiler checks.
reply
deleted
reply
Writing manual Drop isn't usual. And writing drop with such lifetimes is definitely on the weirder scale.
reply
[flagged]
reply
Not really.

The idea is that safe Rust promises that you can't cause UB without unsafe.

Unfortunately there are cases, where the current rust compiler implementation fails to keep that promise. These cases are all tracked as bugs and it's expected they'll be fixed eventually. AFAIK non of the known cases is unfixable, it just takes time and effort, sometime a lot.

Also note that C++ does not make such promises in the first place, so the equivalent code there isn't a bug, it's just UB.

reply