On Mon, Oct 22, 2018 at 04:08:53PM +0200, Martin Liška wrote: > Very valid question. I hope as long as I calculate the linear function > values in wide_int (get via wi::to_wide (switch_element)), then it should > overflow in the same way as original tree type arithmetic. I have a test-case > with > overflow: gcc/testsuite/gcc.dg/tree-ssa/pr84436-4.c. > > Do you have any {over,under)flowing test-cases that I should add to > test-suite?
I'm worried that the calculation you emit into the code could invoke UB at runtime, even if there was no UB in the original code, and later GCC passes would optimize with the assumption that UB doesn't occur. E.g. if the multiplication overflows for one or more of the valid values in the switch and then the addition adds a negative value so that the end result is actually representable. Jakub