[Bug c/69960] "initializer element is not constant"
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 2 15:41:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
--- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> ---
I also agree that accepting it would be a useful extension (perhaps when
diagnosed in pedantic mode to aid portability since other compilers reject it).
As to where C11 rules it out, I believe it's in 6.6 which says that "constant
expressions in initializers ... shall be, or evaluate to, one of the following:
-- an /arithmetic constant expression/,
-- a null pointer constant,
-- an address constant, or
-- an address constant for a complete object type plus or minus an integer
constant expression."
An /arithmetic constant expression/ shall have arithmetic type and shall only
have operands that are integer constants, floating constants, enumeration
constants, character constants, sizeof expressions whose results are integer
constants, and _Alignof expressions.
"f"[0] is none of the above expressions.
C also says that "An implementation may accept other forms of constant
expressions" so accepting it wouldn't be out of line with the requirements.
More information about the Gcc-bugs
mailing list