[PATCH] D44559: [Sema] Wrong width of result of mul operation

Andrew V. Tischenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 27 05:10:24 PDT 2018


avt77 added a comment.

> If that operation overflows, so be it — we're not going to warn about the potential for overflow every time the user adds two ints, and by the same token, it doesn't make any sense to warn about every time the user adds two shorts just because the language made this otherwise-unimportant technical decision to do the arithmetic in a wider type.

There is one comment only: this patch changes the 'mul' operation only and initially the change was done for X86 only because it clearly says about "doubling" of mul result width. And another comment: currently we have warning here:

  int c = a * b;
  T d1 = c; // expected-warning{{implicit conversion loses integer precision: 'int' to 'char'}}

but we don't have it here:

T d2 = a * b; // when T is char

It's a potential problem from my point of view.
But I don't mind to close the review - and the corresponding bug of course.


https://reviews.llvm.org/D44559





More information about the cfe-commits mailing list