History

Fix incorrect one-sided void handling in ?:

Also make the case when one side in ?: is a ptr and the other is neither a ptr nor a null-ptr constant fail cleanly instead of segfaulting.

Petr Skocik committed 7 years ago

Commit f7779ef1 parent 49dfb572 files · +26 −20Browse files

Showing the changes to tests (1 of 2 files). Show all

Unified · Split

tests/tests2/33_ternary_op.c+18−14
@@ -6,20 +6,24 @@ static void f (void){} · 5 unmodified lines
6void (*fp)(void) = f;6void (*fp)(void) = f;
7void call_fp()7void call_fp()
8{8{
9 (fp?f:f)();9 (fp?f:f)();
10 (fp?fp:fp)();10 (fp?fp:fp)();
11 (fp?fp:&f)();11 (fp?fp:&f)();
12 (fp?&f:fp)();12 (fp?&f:fp)();
13 (fp?&f:&f)();13 (fp?&f:&f)();
14 _Generic(0?arr:arr, char*: (void)0);14 _Generic(0?arr:arr, char*: (void)0);
15 _Generic(0?&arr[0]:arr, char*: (void)0);15 _Generic(0?&arr[0]:arr, char*: (void)0);
16 _Generic(0?arr:&arr[0], char*: (void)0);16 _Generic(0?arr:&arr[0], char*: (void)0);
17 _Generic(1?arr:arr, char*: (void)0);17 _Generic(1?arr:arr, char*: (void)0);
18 _Generic(1?&arr[0]:arr, char*: (void)0);18 _Generic(1?&arr[0]:arr, char*: (void)0);
19 _Generic(1?arr:&arr[0], char*: (void)0);19 _Generic(1?arr:&arr[0], char*: (void)0);
20 _Generic((__typeof(1?f:f)*){0}, void (**)(void): (void)0);20 _Generic((__typeof(1?f:f)*){0}, void (**)(void): (void)0);
21 (fp?&f:f)();21 (fp?&f:f)();
22 (fp?f:&f)();22 (fp?f:&f)();
23 _Generic((__typeof(fp?0L:(void)0)*){0}, void*: (void)0);
24
25 //Should cleanly fail, not segfault:
26 /*(fp?f:1);*/
23}27}
24 28
25int main()29int main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t