In C, are const variables guaranteed to be distinct in memory?

前端 未结 4 2173
死守一世寂寞
死守一世寂寞 2021-02-08 02:47

Speaking of string literals, the C99 standard says (6.4.5.6):

It is unspecified whether these arrays are distinct provided their elements have the appropr

4条回答
  •  爱一瞬间的悲伤
    2021-02-08 03:07

    6.4.5/6 says of the arrays corresponding to string literals:

    It is unspecified whether these arrays are distinct provided their elements have the appropriate values.

    So that's a specific rule allowing string literals to be folded. I don't know of anything in the standard that says the same thing for other objects.

提交回复
热议问题