Questions tagged [c23]
C23 is the informal name of the next standard of the C programming language. It replaces C17 and introduces some new features.
66
questions
36
votes
2
answers
3k
views
Why isn't the keyword false an integer constant expression in gcc C23?
Latest gcc 13.x (trunk) gives a compiler error (gcc -std=c23) for this code:
int* p = false;
error: incompatible types when initializing type 'int *' using type '_Bool'
How can this be correct?
C23 ...
18
votes
5
answers
3k
views
Are int main() and int main(void) equivalent prototypes in C23?
C23 introduced new semantics in function declarators:
6.7.6.3 Function declarators
[...]
13 For a function declarator without a parameter type list: the effect is as if it were declared with a ...
17
votes
0
answers
319
views
realloc(ptr, 0) in C23 - now what?
According to the change log of C23, proposal n2464 was voted-in and implemented, making realloc(ptr, 0) explicitly undefined behavior, whereas it was supposedly implementation-defined in previous ...
12
votes
1
answer
8k
views
What is the purpose of the new C23 #embed directive?
A new preprocessor directive is available in the upcoming C23 Standard: #embed
Here is a simple example:
// Placing a small image resource.
#include <stddef.h>
void show_icon(const unsigned ...
11
votes
3
answers
2k
views
C23 auto vs C++11 auto
The C23 standard apparently has introduced using "auto" keyword for auto type deduction, see here, just like in C++11. However, there seems to be some differences.
According to here, https://...
10
votes
2
answers
827
views
What are the [[reproducible]] and [[unsequenced]] attributes in C23, and when should I use them?
C23 introduced the attributes [[reproducible]] and [[unsequenced]].
What is the motivation behind them?
How are they defined, and what effect do they have on a function?
What kind of functions should ...
10
votes
2
answers
280
views
Does nullptr_t break type punning or pointer conversions?
Consider this union:
typedef union
{
void* vptr;
nullptr_t nptr;
} pun_intended;
nullptr_t is supposedly compatible with void* 1). Ok so what if we initialize the void* to some non-zero ...
9
votes
3
answers
1k
views
How can I use "nullptr" for null pointers prior to C23?
In C23, the nullptr keyword got standardized. I would prefer to use nullptr instead of NULL prior to C23 too because it means that I could write code which compiles in:
C, prior to C23
C, since C23
C+...
7
votes
1
answer
200
views
Why doesn't gcc 13 display the correct binary represenation?
While answering a question here, I made the following example:
#include <stdio.h>
#include <math.h>
int main (void)
{
float_t a = -248.75;
printf("%f\n", a);
unsigned ...
7
votes
1
answer
162
views
Existence or not of long_double_t (standard C: C23)
The new standard C (ISO/IEC 9899:2023, aka C23),
in the Annex H, several macros and types are defined,
relative to real and complex arithmetic,
subject to the standard ISO/IEC 60559
(floating-point ...
6
votes
1
answer
268
views
Why does the C23 standard decrease the max size of an object the implementation must support?
I'm currently reading the new draft of the C23 standard (N3088), and I've noticed that in §5.2.4.1 the standard states:
The implementation shall be able to translate and execute a program that uses ...
6
votes
1
answer
128
views
Can you declare a C pointer with its own address?
Can I declare a C pointer with an intialization to its own address?
void* p = &p;
I am specifically concerned with if this is strictly standard compliant in C23 (as the draft currently stands).
I ...
5
votes
5
answers
272
views
How to use typeof_unqual to avoid compiler warnings about discarding const qualifier
In the following code, copyThing() is written so that its return value has the same type as its argument value:
extern void *copyThingImpl(const void *x);
#define copyThing(x) ((typeof(x)) ...
5
votes
1
answer
1k
views
What is the difference between float, _Float32, _Float32x, and _Float32_t?
C23 introduced a number of floating point types, including but not limited to:
_Float32
_Float32x
_Float32_t
I am unsure of the differences, such as:
Are they keywords, or are they type aliases, or ...
5
votes
1
answer
124
views
C2x: 6.9.2 External object definitions: why is "shall not be an incomplete type" placed in Semantics rather than in Constraints?
Follow-up question for: What is the rationale for "semantics violation does not require diagnostics"?.
N2596 working draft — December 11, 2020 ISO/IEC 9899:202x (E), 6.9.2 External object ...