Is it undefined behavior to exceed translation limits and are there checker tools to find it?

后端 未结 3 1109
南笙
南笙 2021-02-13 19:45

ORIGINAL QUESTION:

I\'m searching the C90 standard for things to be aware of, when writing hignly portable code, while having low trust in the good will of the compile

3条回答
  •  旧时难觅i
    2021-02-13 20:08

    It's not undefined behavior, it is implementation defined behavior. This means it all depends on the compiler.

    Yes, the minimal implementation guidelines remain the same or are extended for newer standards versions.

    You probably could use Clang for this, but you'll need to write the tool yourself using the Clang API, I don't know of a pre-existing implementation.


    In any case: the limits aren't set by the standard, "They're more [like] guidelines anyways", (actually nothing more than guidelines). You'll need to check the compilers you use for building the code to see if you're hitting any limits, no way around that by only waving the standards document in someone's nose. And as MSVC's implementation is particularly sucky, I would even dare to say that if it compiles your code (assuming no illegal constructs are in the code itself), you're pretty safe.

提交回复
热议问题