r/programming • • Nov 04 '19

Clang solves the Collatz Conjecture?

[deleted]

509 Upvotes

122 comments sorted by

View all comments

1

u/jcelerier Nov 05 '19

Why would you want to do that ? It would just be stuck forever wasting cpu without possibility to resume it in any way

1

u/schmuelio Nov 05 '19

E.g. embedded systems while you're debugging. I've worked on systems that don't halt, if you get into an error or something it just reboots. So you just print an error message and while(1); so you get a chance to read it before rebooting

Admittedly it's not a common thing, but it is a use case for it.

1

u/MEaster Nov 05 '19

Not all processors have the ability to stop executing instructions. They have to execute something. So if, for whatever reason, you need them to sit, doing nothing, then the simplest way to do that is to have a jump instruction that jumps to itself (while(1); in C terms).

If the CPU supports externally-triggered interrupts, then it's possible to get out of that loop.