List of platforms supported by the C standard

后端 未结 7 2057
粉色の甜心
粉色の甜心 2020-12-01 06:34

Does anyone know of any platforms supported by the C standard, for which there is still active development work, but which are:

  • not 2\'s complement or
相关标签:
7条回答
  • 2020-12-01 07:27

    It should be noted that you cannot rely on undefined behaviour even on commonly used platforms, because modern optimizing compilers perform program transformations that only preserve defined behaviour.

    In particular, you cannot rely on two's complement arithmetic giving you INT_MAX+1 == INT_MIN. For example, gcc 4.6.0 optimizes the following into an infinite loop:

    #include <stdio.h>
    int main() {
         int i = 0;
         while (i++ >= 0)
              puts(".");
         return 0;
    }
    

    EDIT: See here for more on signed overflow and GCC optimizations.

    0 讨论(0)
提交回复
热议问题