title: -Wconversion diagnostic from gcc-trunk when -fsanitize=undefined is passed
body: <p>This is about the correct diagnostics when <code>short int</code>s get promoted during &quot;usual arithmetic conversions&quot;. During operation <code>/</code> a diagnostic could be reasonably emitted, but during <code>/=</code> none should be emitted.</p>
  <p>Behaviour for gcc-trunk and clang-trunk seems OK (neither emits diagnostic for first or second case below)... until...</p>
  <p>we add the entirely unrelated <code>-fsanitize=undefined</code> ... after which, completely bizarrely:</p>
  <p>gcc-trunk emits a diagnostic for both cases. <strong>It really shouldn't for the 2nd case, at least.</strong></p>
  <p>Is this a bug in gcc?</p>
  <p><a href="https://godbolt.org/z/5rbfhY8bW" rel="nofollow noreferrer">Godbolt link</a></p>
  <p><a href="https://godbolt.org/z/aexKEG7zb" rel="nofollow noreferrer">Godbolt link with -O3 - same result</a></p>
  <pre class="lang-cpp prettyprint-override"><code>int main() {
      short sum   = 50;
      short count = 10;
  
      // sum and count get promoted to int for the &quot;usual arithmetic conversions&quot;
      // then the assignment could result in a reasonable -Wconversion diagnostic for reduction back
      // to short
      // However clang-trunk and gcc-trunk choose NOT TO issue a diagnostic with -Wconversion enabled
      short avg1 = sum / count;
  
      // we should be able to prevent promotion to int by using /= assignment operator.
      // Both clang-trunk and gcc-trunk, correctly, DON'T issue a diagnostic with -Wconversion enabled
      auto tmp = sum;
      tmp /= count;
      short avg2 = tmp;
  
      // HOWEVER if we add -fsanitize=undefined for both compilers
      // then, bizarrly, gcc-trunk issues a diagnostic for both cases above and clang-trunk still for
      // neither
  
      // none of these ever issue a diagnostic (nor should they)
      tmp += count; // all
      tmp -= count; // are
      tmp *= count; // silent
  
      return (avg1 + avg2) &amp; 0xff; // prevent &quot;unused&quot; diagnostics
  }
  </code></pre>
  <p><strong>EDIT</strong></p>
  <p>Here is the bug I filed for GCC:
  <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104616" rel="nofollow noreferrer">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104616</a></p>