Why is the maximum size of an array “too large”?

后端 未结 4 1529
谎友^
谎友^ 2020-11-28 11:23

I\'m under the same impression as this answer, that size_t is always guaranteed by the standard to be large enough to hold the largest possible type of a given

4条回答
  •  一向
    一向 (楼主)
    2020-11-28 12:26

    It looks very much like implementation-specific behaviour.

    I'm running here Mac OS, and with gcc 6.3.0 the biggest size I can compile your definition with is SIZE_MAX/2; with SIZE_MAX/2 + 1 it does not compile anymore.

    On the other side, witch clang 4.0.0 the biggest one is SIZE_MAX/8, and SIZE_MAX/8 + 1 breaks.

提交回复
热议问题