[m-rev.] for post-commit review: fix some uint incomplete switches

Julien Fischer jfischer at opturion.com
Tue Mar 7 22:28:31 AEDT 2017


Hi Zoltan,

On Tue, 7 Mar 2017, Zoltan Somogyi wrote:

> For post-commit review by Julien.

The diff looks fine.

...

> I think that one possible solution is to have humans rewrite such code
> as
>
>  require_complete_switch [X]
>  ( X = (<), Result = yes
>  ; X = (=), Result = yes
>  ; X = (>), Result = no
>  ),
>  Result = yes
>
> and then have the simplify pass transform this back to the first version above.
> Since the simplify pass is invoked *after* determinism analysis, which is the
> pass that diagnoses switches that should be complete but aren't, this would get
> the compiler to tell the programmer that the switch should be revisited when
> the type of X has a new functor added to it (such as uint), while avoiding the
> runtime impact of the assignment to, and test of, the extra variable.
>
> What do people think?

I think that would be worthwhile.

Julien.


More information about the reviews mailing list