Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20
@ 2026-08-13  2:54 Tom de Vries
  2026-08-13  3:15 ` Simon Marchi
  2026-08-13  4:34 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Tom de Vries @ 2026-08-13  2:54 UTC (permalink / raw)
  To: gdb-patches

PR build/34514 reports for a C++20 build:
...
cli/cli-style.c:457:37: error: conversion from ‘const char8_t [8]’ to \
  non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} \
  requested
  457 | static std::string warning_prefix = u8"\u26A0\uFE0F ";
      |                                     ^~~~~~~~~~~~~~~~~
...

The u8 literal is char[] until C++20, but char8_t[] since C++20.

Fix this by using a reinterpret_cast<const char *>.

Tested by rebuilding using GCC 15.3.0, with and without -std=c++20.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34514
---
 gdb/cli/cli-style.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 60c00acdf43..5c26519c6d7 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -454,7 +454,8 @@ no_emojis ()
    - uFE0F: Variation Selector-16 (VS16)
    The VS16 forces "Emoji" presentation.  It is needed because the default
    presentation for Warning Sign is "Text".  Together, we get: ⚠️ .  */
-static std::string warning_prefix = u8"\u26A0\uFE0F ";
+static std::string warning_prefix
+  = reinterpret_cast<const char *> (u8"\u26A0\uFE0F ");
 
 /* Implement 'show style warning-prefix'.  */
 
@@ -479,7 +480,8 @@ print_warning_prefix (ui_file *file)
    - u274C: Cross Mark: ❌
    No VS16 is needed because the default presentation for Cross Mark is
    "Emoji".  */
-static std::string error_prefix = u8"\u274C ";
+static std::string error_prefix
+  = reinterpret_cast<const char *> (u8"\u274C ");
 
 /* Implement 'show style error-prefix'.  */
 

base-commit: dbf19e0f878eb592011c25c1dbbfc35eee330ec2
-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20
  2026-08-13  2:54 [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20 Tom de Vries
@ 2026-08-13  3:15 ` Simon Marchi
  2026-08-13  4:34 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2026-08-13  3:15 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

On 8/12/26 10:54 PM, Tom de Vries wrote:
> PR build/34514 reports for a C++20 build:
> ...
> cli/cli-style.c:457:37: error: conversion from ‘const char8_t [8]’ to \
>   non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} \
>   requested
>   457 | static std::string warning_prefix = u8"\u26A0\uFE0F ";
>       |                                     ^~~~~~~~~~~~~~~~~
> ...
> 
> The u8 literal is char[] until C++20, but char8_t[] since C++20.
> 
> Fix this by using a reinterpret_cast<const char *>.
> 
> Tested by rebuilding using GCC 15.3.0, with and without -std=c++20.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34514

Seems fine to me, I don't see a better way around it, other than moving
back to having the emoji in the code.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20
  2026-08-13  2:54 [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20 Tom de Vries
  2026-08-13  3:15 ` Simon Marchi
@ 2026-08-13  4:34 ` Eli Zaretskii
  2026-08-13 11:53   ` Tom de Vries
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2026-08-13  4:34 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

> From: Tom de Vries <tdevries@suse.de>
> Date: Thu, 13 Aug 2026 04:54:45 +0200
> 
> PR build/34514 reports for a C++20 build:
> ...
> cli/cli-style.c:457:37: error: conversion from ‘const char8_t [8]’ to \
>   non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} \
>   requested
>   457 | static std::string warning_prefix = u8"\u26A0\uFE0F ";
>       |                                     ^~~~~~~~~~~~~~~~~
> ...
> 
> The u8 literal is char[] until C++20, but char8_t[] since C++20.
> 
> Fix this by using a reinterpret_cast<const char *>.
> 
> Tested by rebuilding using GCC 15.3.0, with and without -std=c++20.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34514
> ---
>  gdb/cli/cli-style.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
> index 60c00acdf43..5c26519c6d7 100644
> --- a/gdb/cli/cli-style.c
> +++ b/gdb/cli/cli-style.c
> @@ -454,7 +454,8 @@ no_emojis ()
>     - uFE0F: Variation Selector-16 (VS16)
>     The VS16 forces "Emoji" presentation.  It is needed because the default
>     presentation for Warning Sign is "Text".  Together, we get: ⚠️ .  */
> -static std::string warning_prefix = u8"\u26A0\uFE0F ";
> +static std::string warning_prefix
> +  = reinterpret_cast<const char *> (u8"\u26A0\uFE0F ");
>  
>  /* Implement 'show style warning-prefix'.  */
>  
> @@ -479,7 +480,8 @@ print_warning_prefix (ui_file *file)
>     - u274C: Cross Mark: ❌
>     No VS16 is needed because the default presentation for Cross Mark is
>     "Emoji".  */
> -static std::string error_prefix = u8"\u274C ";
> +static std::string error_prefix
> +  = reinterpret_cast<const char *> (u8"\u274C ");

Thanks.  May I suggest to add comments here explaining why we use
reinterpret_cast?  The situation with the various C++ standards
changes with time, as we require newer versions of the standard, so at
some point this will no longer be needed.  And use of reinterpret_cast
is unusual enough to raise some brows anyway.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20
  2026-08-13  4:34 ` Eli Zaretskii
@ 2026-08-13 11:53   ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-08-13 11:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 8/13/26 6:34 AM, Eli Zaretskii wrote:
>> From: Tom de Vries <tdevries@suse.de>
>> Date: Thu, 13 Aug 2026 04:54:45 +0200
>>
>> PR build/34514 reports for a C++20 build:
>> ...
>> cli/cli-style.c:457:37: error: conversion from ‘const char8_t [8]’ to \
>>    non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} \
>>    requested
>>    457 | static std::string warning_prefix = u8"\u26A0\uFE0F ";
>>        |                                     ^~~~~~~~~~~~~~~~~
>> ...
>>
>> The u8 literal is char[] until C++20, but char8_t[] since C++20.
>>
>> Fix this by using a reinterpret_cast<const char *>.
>>
>> Tested by rebuilding using GCC 15.3.0, with and without -std=c++20.
>>
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34514
>> ---
>>   gdb/cli/cli-style.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
>> index 60c00acdf43..5c26519c6d7 100644
>> --- a/gdb/cli/cli-style.c
>> +++ b/gdb/cli/cli-style.c
>> @@ -454,7 +454,8 @@ no_emojis ()
>>      - uFE0F: Variation Selector-16 (VS16)
>>      The VS16 forces "Emoji" presentation.  It is needed because the default
>>      presentation for Warning Sign is "Text".  Together, we get: ⚠️ .  */
>> -static std::string warning_prefix = u8"\u26A0\uFE0F ";
>> +static std::string warning_prefix
>> +  = reinterpret_cast<const char *> (u8"\u26A0\uFE0F ");
>>   
>>   /* Implement 'show style warning-prefix'.  */
>>   
>> @@ -479,7 +480,8 @@ print_warning_prefix (ui_file *file)
>>      - u274C: Cross Mark: ❌
>>      No VS16 is needed because the default presentation for Cross Mark is
>>      "Emoji".  */
>> -static std::string error_prefix = u8"\u274C ";
>> +static std::string error_prefix
>> +  = reinterpret_cast<const char *> (u8"\u274C ");
> 
> Thanks.  May I suggest to add comments here explaining why we use
> reinterpret_cast?  The situation with the various C++ standards
> changes with time, as we require newer versions of the standard, so at
> some point this will no longer be needed.  And use of reinterpret_cast
> is unusual enough to raise some brows anyway.

Hi Eli,

I've sent a patch that adds a comment but also replaces the 
reinterpret_cast ( 
https://sourceware.org/pipermail/gdb-patches/2026-August/229432.html ).

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-13 11:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-13  2:54 [PATCH] [gdb/build] Fix cli/cli-style.c build error with C++20 Tom de Vries
2026-08-13  3:15 ` Simon Marchi
2026-08-13  4:34 ` Eli Zaretskii
2026-08-13 11:53   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox