[PATCH] D22441: Fix isShiftedInt and isShiftedUint for widths > 32.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 18 12:55:24 PDT 2016


jlebar added a comment.

> 1> .\llvm\include\llvm/Support/MathExtras.h(296): warning C4293: '<<': shift count negative or too big, undefined behavior

>  1> .\llvm\include\llvm/Support/MathExtras.h(322): note: see reference to function template instantiation 'bool llvm::isUInt<64>(uint64_t)' being compiled

>  1> .\llvm\unittests\Support\MathExtrasTest.cpp(401): note: see reference to function template instantiation 'bool llvm::isShiftedUInt<1,63>(uint64_t)' being compiled


Ugh.  I think MSVC is wrong.  isUInt<64> does

  return N >= 64 || x < (UINT64_C(1)<<(N));

Which should be safe because of short-circuit evaluation.

I guess we can specialize the isUInt<N> template.  :-/  Can we file a bug on msvc?


Repository:
  rL LLVM

https://reviews.llvm.org/D22441





More information about the llvm-commits mailing list