logoalt Hacker News

echoangleyesterday at 3:39 PM2 repliesview on HN

The article mentions a use case for that:

> What I found is that this is common in embedded and kernel code as a halt-on-error pattern. When a fatal error occurs and there’s no operating system to exit to, you simply stop:


Replies

pdonisyesterday at 4:09 PM

If this is a genuine use case, I wonder why the language can't just introduce a built-in function for it. For example, std::get_stuck_here(). Then the compiler would know not to optimize this away. The implementation under the hood could still be an infinite loop, but the compiler would not have to guess why it's there.

show 2 replies
account42yesterday at 3:50 PM

Low level code can and should use assembly to get the precise effect they desire in these cases.

show 3 replies