Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by LegionMammal978 on Monday May 15, 2023 @03:10PM
(#35953137)
That's a compiler extension. In C17, 6.5.16.1 (Simple assignment) implies that the RHS of an assignment to a pointer must either have pointer type or be a null pointer constant (i.e., an integer constant equal to 0, or such a constant casted to pointer type), and 6.7.9 (Initialization) states that "the same type constraints and conversions as for simple assignment apply" to expressions used as initializers.
[ Parent
| on HN ]
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by Kamq on Monday May 15, 2023 @11:27PM
(#35957448)
"standard" C implies default to me, so the post is probably referring to C89 or C99, which are significantly more used than C17.
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by LegionMammal978 on Tuesday May 16, 2023 @02:02AM
(#35958197)
This particular rule is essentially unchanged from C89 (3.5.7 for initialization, 3.3.16.1 for simple assignment) and from C99 (6.7.8 for initialization, 6.5.16.1 for simple assignment). Generally, most existing rules don't change much at all across the C Standard versions.
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by ynik on Tuesday May 16, 2023 @04:59AM
(#35959243)
"Standard C" is the C that was standardized.
This is not what you get from your compiler by default!
With gcc, you have to use `gcc -std=c99 -pedantic-errors`, otherwise it will accept programs which are invalid according to the standard.