Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by bigbillheck on Monday May 15, 2023 @03:55PM
(#35953619)
> NULL is idiomatic
It is today, but idioms are a human concept and who knows how things will be in 2033?
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by kllrnohj on Monday May 15, 2023 @06:44PM
(#35955527)
Well hopefully at some point we'll stop writing C at all
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by bigbillheck on Monday May 15, 2023 @07:40PM
(#35956021)
Inshallah some day, but I don't see it happening in what's left of my career.
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by pjmlp on Monday May 15, 2023 @04:16PM
(#35953903)
Once upon a time K&R C function declarations were idiomatic, in C23 they are out.
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by cogman10 on Monday May 15, 2023 @04:54PM
(#35954345)
> In spite of nullptr existing now, NULL is still (quite stupidly) not required to just expand to nullptr, but to an implementation-defined null pointer constant, rather than #define NULL nullptr. (According to the N2596 draft).
This is so silly. I sort of get why not (can't break the dork that decided to do
int i = NULL;
i++;
)But, at the same time... I almost feel like this is a "you are being a dork, go fix your code." moment. This isn't the sort of break where someone would see it and go "Oh yeah, assuming NULL is anything other than nullptr is dumb!"
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by kazinator on Monday May 15, 2023 @06:32PM
(#35955405)
> can't break the dork that decided to
Why not? We've broken the dork who used undeclared functions, void main, gets ...
(It's the same funking dork anyway. You know who you are, I'm looking at you!)
Note that
int x = ((void *) 0);
will actually work in GCC and get you a zero into x, just with a conversion warning. The dork is unaffected; their code works and they don't read warnings.
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha...
by GabrielTFS on Wednesday May 17, 2023 @11:00AM
(#35976240)
See https://gcc.gnu.org/pipermail/gcc/2023-May/241264.html for why this might not be the case anymore soon - although I suppose that adding in -fpermissive or -Wno-error=conversion or something like that isn't too much effort.
- NULL is idiomatic: using NULL is entrenched in C programming and it is not going away.
- In spite of nullptr existing now, NULL is still (quite stupidly) not required to just expand to nullptr, but to an implementation-defined null pointer constant, rather than #define NULL nullptr. (According to the N2596 draft).
- They had over 30 years to tighten the requirements on how NULL can be defined; what's the matter? C99 could already have required NULL to be ((void *) X) where X is an integer-typed constant expression evaluating to zero.
I'm not going to start using nullptr. It's not idiomatic C. I'm going to hold out hope that NULL will be fixed so that it expands to nullptr.
--
Also, it's possible for a compiler to diagnose when a constant, zero-valued expression is used as the argument of a variadic function. The diagnostic can be confined to cases when such a constant expression is the result of macro expansion: