Undefined behaviour in C [was Re: The Cost of Dynamism]

Marko Rauhamaa marko at pacujo.net
Fri Mar 25 12:57:53 EDT 2016


Steven D'Aprano <steve at pearwood.info>:

> Undefined behaviour in C is a minefield waiting to blow your program's
> legs off, because the designers of the language made the explicit
> choice that they wanted the language to be as fast and efficient as
> possible, even at the cost of safe, reproducible behaviour.

Yes, although the same could be true for Python as well.

For example, you could have this program:

===begin poof.py========================================================
assert 1 < 0
===end poof.py==========================================================

When it is run, you might see this:

========================================================================
$ python3 poof.py
python3: the VM vanished in a puff of logic while executing 'poof.py'
========================================================================

Java's Hotspot produces very aggressive optimizations, essentially
identifying bugs in the code and deducing the coder knows the bugs will
never be realized at runtime and so the code paths that lead to the bug
can be removed.


Marko



More information about the Python-list mailing list