Why it is allowed to initialize static variable with non const here?

前端 未结 2 1401
栀梦
栀梦 2021-01-06 07:48

I was reading this. The first answer by @Andrei T says that

A \"large\" object is never a constant expression in C, even if the object is declared a

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 08:38

    This seems to be a gcc speciality. Compiling with -std=c89 or -pedantic reports the error.

    Since in all C standards this is a constraint violation, not giving a diagnostic for that case makes gcc without one of the -std=c?? options a non-conforming compiler.

提交回复
热议问题