[clang] Add support for builtin_verbose_trap (PR #79230)

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 26 07:57:22 PST 2024


================
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify %s
+
+#if !__has_builtin(__builtin_verbose_trap)
+#error
+#endif
+
+constexpr char const* constMsg1 = "hello";
+char const* const constMsg2 = "hello";
+char const constMsg3[] = "hello";
+
+template <const char * const str>
+void f(const char * arg) {
+  __builtin_verbose_trap("Argument_must_not_be_null");
----------------
ahatanak wrote:

I noticed that the code doesn't compile in `c++20` because the type of UTF8 string literals is `char8_t[N]` instead of `char[N]`. This is the error message:

`cannot initialize a parameter of type 'const char *' with an lvalue of type 'const char8_t[21]'`

It compiles if I cast it to the correct type (`__builtin_verbose_trap((const char *)u8"¡¢£¤¥¦§¨©ª");`).

How important is it to be able to pass UTF8 string literals to the builtin in c++20 without using any casts?

https://github.com/llvm/llvm-project/pull/79230


More information about the cfe-commits mailing list