Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Undefined behaviour" has a very specific meaning (perhaps ironically) in programming language design. It means anything could happen, including crashing during the undefined operation (i.e. crashing during the sort() in this case), appearing to work but then crashing afterwards, or even crashing before the undefined operation starts! (Or doing other weird things, not just crashing - but a time travelling crash is already plenty weird enough for this discussion.)

If Rust is able to define its sort() as only ever affecting the array passed to it, with the possibility of looping forever, then that is very well defined behaviour in comparison.



Yup. If the only potential variation is on the resulting ordering, C/C++ would call this implementation-defined or unspecified than undefined.

One example of unspecified behaviour is the order in which function call parameters are evaluated (meaning any order is OK, and it could vary from call to call).

One example of implementation-defined behaviour is the value of sizeof(int).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: