You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This paper removes UB around use of void expressions. Previously, code
like this had undefined behavior:
void foo(void) {
(void)(void)1;
extern void x;
x;
}
and this is now well-defined in C2y. Functionally, this now means that
it is valid to use `void` as a `_Generic` association.
* Removes the requirement that an expression with type void cannot be used in
10
+
* any way. This was making it UB to use a void expression in a _Generic
11
+
* selection expression for no good reason, as well as making it UB to cast a
12
+
* void expression to void, etc.
13
+
*/
14
+
15
+
externvoidx;
16
+
voidfoo() {
17
+
// FIXME: this is technically an extension before C2y and should be diagnosed
18
+
// under -pedantic.
19
+
(void)(void)1;
20
+
// FIXME: same with this.
21
+
x;
22
+
_Generic(x, void: 1); /* pre-c2y-warning {{use of an incomplete type in a '_Generic' association is incompatible with C standards before C2y; 'void' is an incomplete type}}
23
+
ext-warning {{ISO C requires a complete type in a '_Generic' association; 'void' is an incomplete type}}
24
+
*/
25
+
_Generic(x, typeof(x): 1); /* pre-c2y-warning {{use of an incomplete type in a '_Generic' association is incompatible with C standards before C2y; 'typeof (x)' (aka 'void') is an incomplete type}}
26
+
ext-warning {{ISO C requires a complete type in a '_Generic' association; 'typeof (x)' (aka 'void') is an incomplete type}}
27
+
*/
28
+
(void)_Generic(void, default : 1); /* pre-c2y-warning {{passing a type argument as the first operand to '_Generic' is incompatible with C standards before C2y}}
29
+
ext-warning {{passing a type argument as the first operand to '_Generic' is a C2y extension}}
0 commit comments