(cond ? 0 : ptr)->member wasn't handled correctly. If one arm is a null pointer constant (which also can be a pointer) the result type is that of the other arm.
Showing the changes to tests (1 of 2 files). Show all
Unified · Split
| @@ -2486,3 +2486,16 @@ void const_warn_test(void) · 2485 unmodified lines | ||
| 2486 | 2486 | { |
| 2487 | 2487 | const_func(1); |
| 2488 | 2488 | } |
| 2489 | + | |
| 2490 | +struct condstruct { | |
| 2491 | + int i; | |
| 2492 | +}; | |
| 2493 | + | |
| 2494 | +int getme (struct condstruct *s, int i) | |
| 2495 | +{ | |
| 2496 | + int i1 = (i == 0 ? 0 : s)->i; | |
| 2497 | + int i2 = (i == 0 ? s : 0)->i; | |
| 2498 | + int i3 = (i == 0 ? (void*)0 : s)->i; | |
| 2499 | + int i4 = (i == 0 ? s : (void*)0)->i; | |
| 2500 | + return i1 + i2 + i3 + i4; | |
| 2501 | +} | |