[libcxx-commits] [PATCH] D146372: [libc++]Don't warn when using operator<=> with 0

Igor Zhukov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 19 04:32:56 PDT 2023


fsb4000 marked 2 inline comments as done.
fsb4000 added inline comments.


================
Comment at: libcxx/include/__compare/ordering.h:43
 struct _CmpUnspecifiedParam {
-  _LIBCPP_HIDE_FROM_ABI constexpr
-  _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
+  _LIBCPP_HIDE_FROM_ABI consteval
+  _CmpUnspecifiedParam(int __literal_zero) noexcept {
----------------
philnik wrote:
> 
Thanks!


================
Comment at: libcxx/include/__compare/ordering.h:46
+    if (__literal_zero != 0) {
+      __builtin_abort();
+    }
----------------
philnik wrote:
> This produces way better error messages on most compilers: https://godbolt.org/z/PhjaTav68
Yes, the error messages are better but if I remember correctly we can't use `throw` because we need to support no-exceptions.


================
Comment at: libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp:1
 //===----------------------------------------------------------------------===//
 //
----------------
philnik wrote:
> I think this test should be inside `test/libcxx`, since it is very implementation-specific.
Ok.


================
Comment at: libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp:10
 // UNSUPPORTED: c++03, c++11, c++14, c++17
+// ADDITIONAL_COMPILE_FLAGS: -Wzero-as-null-pointer-constant
 
----------------
philnik wrote:
> Is there a reason we can't enable this globally?
Ok, I will try. 
Let's see if that break something.


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

https://reviews.llvm.org/D146372



More information about the libcxx-commits mailing list