Remix.run Logo
▲ weinzierl 3 hours 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).

▲theemathas 2 hours ago | parent | next [-]

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.

▲Groxx 11 minutes ago | parent [-]

Yeah, if my read of maxdexh's comment¹ is right, this is a remarkably straightforward gap. Definitely surprising it survived this long.

1: https://github.com/rust-lang/rust/issues/164250#issuecomment...

▲rurban an hour ago | parent | prev [-]

Wait, shock! So you say rust is unsafe by default?

▲weinzierl an hour ago | parent [-]

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.