Constant array types in C, flaw in standard?

前端 未结 3 1858
迷失自我
迷失自我 2021-01-04 02:21

Paragraph 6.7.3.8 of the C99 spec states

If the specification of an array type includes any type qualifiers, the element type is so-qualified, not the array ty
3条回答
  •  情话喂你
    2021-01-04 02:48

    This is a known issue that has been discussed several times over the last 10 years at comp.std.c. The bottom line is that the specific case you presented is not currently legal in Standard C; you need to either remove the qualifier or refrain from using a pointer to an array to refer to the qualified elements in the array.

    If you think you have a good idea to overcome the issue, you can post it to news:comp.std.c for discussion. If others agree that it is a good idea, you or someone else can file a defect report to have the behavior changed (there are several committee members that frequent comp.std.c so feedback from the people who would potentially be reviewing the DR would be useful to have prior to filing it). I think there may be some issues with your proposal to have qualifiers affect the array itself, but I'd have to give it some more thought.

提交回复
热议问题