[PATCH] D62825: [C++2a] Add __builtin_bit_cast, used to implement std::bit_cast

Richard Smith - zygoloid via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 18:09:33 PDT 2019


rsmith added inline comments.


================
Comment at: clang/lib/AST/ExprConstant.cpp:5447
+
+    case APValue::LValue: {
+      LValue LVal;
----------------
jfb wrote:
> rsmith wrote:
> > This will permit bitcasts from `nullptr_t`, providing a zero value. I think that's wrong; the bit representation of `nullptr_t` is notionally uninitialized (despite strangely having pointer size and alignment).
> > 
> > I think this is a specification bug: `bit_cast<intptr_t>(nullptr)` should be non-constant (it won't necessarily be `0` at runtime) but the current wording doesn't seem to permit us to treat it as non-constant.
> You brought this up in ABQ, the outcome was... poor notes so I have no idea what Core decided...
It looks like we never actually resolved what happens in this case ;-(


================
Comment at: clang/lib/AST/ExprConstant.cpp:5549
+  // Ideally this will be unreachable.
+  llvm::NoneType unsupportedType(QualType Ty) {
+    Info.FFDiag(BCE->getBeginLoc(),
----------------
Support for bitcasting to `nullptr_t` seems to be missing.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62825/new/

https://reviews.llvm.org/D62825





More information about the llvm-commits mailing list