https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66313

--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Dmitry Babokin from comment #16)
> Here's another test case with a contrary example, where a variable gets
> pulled into the braces and it also causes false positive. Transformation is:
> const1 * (const2 * var1 - const3 * var2) => const1*const2*var1 - const3*var2;
> 
> > cat f.cpp
> #include <iostream>
> signed char var_10 = 77;
> long long int var_13 = 1547580415367384384LL;
> 
> long foo() {
>   long a = -6 *
>             // 0xbf8a6c24aa342bc0 = -4644781160949077056
>            (long(16636733186465668563ULL * var_13 ) -
>             // 0xd4cdd0f8c2df13cf = -3112602000603278385
>             long(678280911954875019ULL * var_10));
>   return a;
> }
> 
> int main () {
>     long a = foo ();
>     std::cout << a << std::endl;
>     return 0;
> }
> 
> > g++ -fsanitize=undefined -O0 f.cpp; ./a.out
> f.cpp:6:8: runtime error: signed integer overflow: -9024801181724640896 -
> 228867929910118694 cannot be represented in type 'long int'
> 9193074962074792026
> 
> If it's unrelated issue, let me know and I'll file a separate bug for it.

Yes, that's an unrelated issue -- extract_muldiv likely.

Reply via email to