logoalt Hacker News

vincent-uden • today at 11:00 AM • 4 replies • view on HN

What the hell. This is not the esoteric, crazy, impractical constellation I expected to find with a title like this. The minimal example is so simple and is definitely something you'd easily come across in normal code.


Replies

insanitybit • today at 11:10 AM

For a long time `loop {}` was undefined behavior. Lots of l-unsounds are really nuts but a few are not.

The reality is that if this were actually code that people wrote, well, it wouldn't have sat around for a decade.

➕ show 1 reply
fg137 • today at 12:20 PM

> is definitely something you'd easily come across in normal code.

The fact that nobody reported this before means it's not, by definition.

➕ show 1 reply
LoganDark • today at 11:05 AM

I wonder if the reason it works is because you'd easily come across it in normal code, and someone didn't realize that saving the effort of implementing a check for this would result in unsoundness.

➕ show 1 reply
jvanderbot • today at 11:08 AM

Not really. I've worked with rust for 4 years, systems side, and never had to write a custom drop implementation. That's the gotcha here, not the rigamarole with the static+Send option type (which _would_ be something you'd encounter in prod).

➕ show 5 replies