From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113839 invoked by alias); 7 Oct 2019 17:46:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113721 invoked by uid 89); 7 Oct 2019 17:46:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 17:46:22 +0000 Received: from [172.16.0.148] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BA38B1E61D; Mon, 7 Oct 2019 13:46:20 -0400 (EDT) Subject: Re: [PATCH] Use gdb_static_assert in charset.c To: Christian Biesinger , gdb-patches@sourceware.org References: <20191007173510.250346-1-cbiesinger@google.com> From: Simon Marchi Message-ID: <4200cedb-f9ff-6041-acbd-991ea88fb502@simark.ca> Date: Mon, 07 Oct 2019 17:46:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191007173510.250346-1-cbiesinger@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-10/txt/msg00195.txt.bz2 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 > > * 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