• henfredemars@lemdro.id
    link
    fedilink
    English
    arrow-up
    2
    ·
    21 hours ago

    There’s also this part of the standard that throws a wrench into this hypothesis:

    §5.1.2.3/4: (Program execution, Observable behavior):

    Accesses to volatile objects and calls to library I/O functions are observable behavior. The implementation may perform any transformation of a program, provided that the resulting program’s observable behavior is not changed.

    So it seems that running forever isn’t an observable property that must be preserved when code is transformed.

    Still, I think compilers try to not surprise the developer too badly and would recognize a trivial loop most of the time.