Comment by weinzierl

11 days ago

This is remarkable but not super unusual. There are more than 100 issues labeled unsound currently. Some are long standing but from what I understand the new trait solver will unblock fixes for some of them (but probably not the one in OP).

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.

  • Writing manual Drop isn't usual. And writing drop with such lifetimes is definitely on the weirder scale.

[flagged]

  • 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.