Commit 40dd705
authored
Placate Green Hills compiler with ternary (#670)
When the Green Hills compiler encounters an if/else branch whose
predicate is known at compile time, it complains about an unreachable
statement. Even if the predicate depends on template parameters (i.e.,
is not a strict constant _across all template instantiations_), the
policy triggers on any _individual_ instantiations that contain an
unreachable statement.
Leaving aside the wisdom of this policy as it pertains to generic
programming, the fact is that we're stuck with it and we need to keep
the compiler happy.
To fix this instance, we simply use a ternary operator. The ternary is
just the same as an if/else branch, but it's a single statement. In
testing on AV code, this does seem to placate the Green Hills compiler.1 parent 860ae5f commit 40dd705
1 file changed
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
| |||
0 commit comments