2 extern int printf(const char*, ...);
14 _Generic(0?arr
:arr
, char*: (void)0);
15 _Generic(0?&arr
[0]:arr
, char*: (void)0);
16 _Generic(0?arr
:&arr
[0], char*: (void)0);
17 _Generic(1?arr
:arr
, char*: (void)0);
18 _Generic(1?&arr
[0]:arr
, char*: (void)0);
19 _Generic(1?arr
:&arr
[0], char*: (void)0);
20 _Generic((__typeof(1?f
:f
)*){0}, void (**)(void): (void)0);
23 _Generic((__typeof(fp
?0L:(void)0)*){0}, void*: (void)0);
25 /* The following line causes a warning */
33 static int getme(struct condstruct
* s
, int i
)
35 int i1
= (i
!= 0 ? 0 : s
)->i
;
36 int i2
= (i
== 0 ? s
: 0)->i
;
37 int i3
= (i
!= 0 ? (void*)0 : s
)->i
;
38 int i4
= (i
== 0 ? s
: (void*)0)->i
;
39 return i1
+ i2
+ i3
+ i4
;
46 for (Count
= 0; Count
< 10; Count
++)
48 printf("%d\n", (Count
< 5) ? (Count
*Count
) : (Count
* 3));
53 #define ASSERT(X) assert(X)
54 static struct stru
{ int x
; } a
={'A'},b
={'B'};
55 static const struct stru2
{ int x
; } d
= { 'D' };
56 ASSERT('A'==(*(1?&a
:&b
)).x
);
57 ASSERT('A'==(1?a
:b
).x
);
58 ASSERT('A'==(c
?b
:a
).x
);
59 ASSERT('A'==(0?b
:a
).x
);
61 ASSERT('A'==(c
?a
:b
).x
);
62 ASSERT(sizeof(int) == sizeof(0 ? 'a' : c
));
63 ASSERT(sizeof(double) == sizeof(0 ? 'a' : 1.0));
64 ASSERT(sizeof(double) == sizeof(0 ? 0.0 : 'a'));
65 ASSERT(sizeof(float) == sizeof(0 ? 'a' : 1.0f
));
66 ASSERT(sizeof(double) == sizeof(0 ? 0.0 : 1.0f
));
67 struct condstruct cs
= { 38 };
68 printf("%d\n", getme(&cs
, 0));
70 // the following lines contain type mismatch errors in every ternary expression
71 //printf("comparing double with pointer : size = %d\n", sizeof(0 ? &c : 0.0));
72 //printf("'%c' <> '%c'\n", (0 ? a : d).x, (1 ? a : d).x);
80 /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/