[PATCH] D153702: [Clang] Implement P2738R1 - constexpr cast from void*

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 01:49:22 PDT 2023


cor3ntin added inline comments.


================
Comment at: clang/test/CXX/expr/expr.const/p5-26.cpp:13
+    (void)static_cast<T*>(a); //cxx23-note {{cast from 'void *' is not allowed in a constant expression in C++ standards before C++2c}}
+    (void)static_cast<const T*>(a);
+    (void)static_cast<volatile T*>(a);
----------------
shafik wrote:
> Why no diagnostic on this line and the next?
Why do you expect one?
you can add const/volatile (but not remove const) in a static_cast https://godbolt.org/z/qEqoEWohc
In c++23, no diag because we stop evaluating the function at that point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153702



More information about the cfe-commits mailing list