Commit 2743450
committed
MathUtils: make getMean()'s ternary unambiguous for an emulated double
On Metal the double keyword names a class that converts to float and back
implicitly, so the conditional operator has to form an implicit conversion
sequence from each arm to the type of the other. Both directions succeed and the
standard has no tie-break, which makes wsum > 0. ? sum / wsum : 0. ill-formed
there. With a builtin double the arms go through the usual arithmetic
conversions instead, and those are ranked, so nothing has to be resolved.
double{} gives both arms the declared type on every backend: zero for the
builtin, and, since the emulated type's default constructor is not user-provided,
an all-bits-zero +0.0 on Metal.1 parent 926fc42 commit 2743450
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments