* [PATCH] Use gdb_static_assert in charset.c
@ 2019-10-07 17:35 Christian Biesinger via gdb-patches
2019-10-07 17:46 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-10-07 17:35 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
It currently has a "manual" static assert.
gdb/ChangeLog:
2019-10-07 Christian Biesinger <cbiesinger@google.com>
* charset.c (your_gdb_wchar_t_is_bogus): Replace with a
gdb_static_assert.
---
gdb/charset.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/gdb/charset.c b/gdb/charset.c
index 9df46c0c74d..73131651a6d 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -946,15 +946,9 @@ default_auto_wide_charset (void)
#define ENDIAN_SUFFIX "LE"
#endif
-/* The code below serves to generate a compile time error if
- gdb_wchar_t type is not of size 2 nor 4, despite the fact that
- macro __STDC_ISO_10646__ is defined.
- This is better than a gdb_assert call, because GDB cannot handle
- strings correctly if this size is different. */
-
-extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2
- || sizeof (gdb_wchar_t) == 4)
- ? 1 : -1];
+/* GDB cannot handle strings correctly if this size is different. */
+
+gdb_static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4);
/* intermediate_encoding returns the charset used internally by
GDB to convert between target and host encodings. As the test above
--
2.23.0.581.g78d2f28ef7-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Use gdb_static_assert in charset.c
2019-10-07 17:35 [PATCH] Use gdb_static_assert in charset.c Christian Biesinger via gdb-patches
@ 2019-10-07 17:46 ` Simon Marchi
2019-10-07 17:51 ` Christian Biesinger via gdb-patches
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2019-10-07 17:46 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
On 2019-10-07 1:35 p.m., Christian Biesinger via gdb-patches wrote:
> It currently has a "manual" static assert.
>
> gdb/ChangeLog:
>
> 2019-10-07 Christian Biesinger <cbiesinger@google.com>
>
> * charset.c (your_gdb_wchar_t_is_bogus): Replace with a
> gdb_static_assert.
> ---
> gdb/charset.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/charset.c b/gdb/charset.c
> index 9df46c0c74d..73131651a6d 100644
> --- a/gdb/charset.c
> +++ b/gdb/charset.c
> @@ -946,15 +946,9 @@ default_auto_wide_charset (void)
> #define ENDIAN_SUFFIX "LE"
> #endif
>
> -/* The code below serves to generate a compile time error if
> - gdb_wchar_t type is not of size 2 nor 4, despite the fact that
> - macro __STDC_ISO_10646__ is defined.
> - This is better than a gdb_assert call, because GDB cannot handle
> - strings correctly if this size is different. */
> -
> -extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2
> - || sizeof (gdb_wchar_t) == 4)
> - ? 1 : -1];
> +/* GDB cannot handle strings correctly if this size is different. */
> +
> +gdb_static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4);
>
> /* intermediate_encoding returns the charset used internally by
> GDB to convert between target and host encodings. As the test above
>
Thanks, LGTM.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Use gdb_static_assert in charset.c
2019-10-07 17:46 ` Simon Marchi
@ 2019-10-07 17:51 ` Christian Biesinger via gdb-patches
0 siblings, 0 replies; 3+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-10-07 17:51 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On Mon, Oct 7, 2019 at 12:46 PM Simon Marchi <simark@simark.ca> wrote:
>
> On 2019-10-07 1:35 p.m., Christian Biesinger via gdb-patches wrote:
> > It currently has a "manual" static assert.
> >
> > gdb/ChangeLog:
> >
> > 2019-10-07 Christian Biesinger <cbiesinger@google.com>
> >
> > * charset.c (your_gdb_wchar_t_is_bogus): Replace with a
> > gdb_static_assert.
> > ---
> > gdb/charset.c | 12 +++---------
> > 1 file changed, 3 insertions(+), 9 deletions(-)
> >
> > diff --git a/gdb/charset.c b/gdb/charset.c
> > index 9df46c0c74d..73131651a6d 100644
> > --- a/gdb/charset.c
> > +++ b/gdb/charset.c
> > @@ -946,15 +946,9 @@ default_auto_wide_charset (void)
> > #define ENDIAN_SUFFIX "LE"
> > #endif
> >
> > -/* The code below serves to generate a compile time error if
> > - gdb_wchar_t type is not of size 2 nor 4, despite the fact that
> > - macro __STDC_ISO_10646__ is defined.
> > - This is better than a gdb_assert call, because GDB cannot handle
> > - strings correctly if this size is different. */
> > -
> > -extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2
> > - || sizeof (gdb_wchar_t) == 4)
> > - ? 1 : -1];
> > +/* GDB cannot handle strings correctly if this size is different. */
> > +
> > +gdb_static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4);
> >
> > /* intermediate_encoding returns the charset used internally by
> > GDB to convert between target and host encodings. As the test above
> >
>
> Thanks, LGTM.
Thanks, pushed.
Christian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-07 17:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 17:35 [PATCH] Use gdb_static_assert in charset.c Christian Biesinger via gdb-patches
2019-10-07 17:46 ` Simon Marchi
2019-10-07 17:51 ` Christian Biesinger via gdb-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).