From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23997 invoked by alias); 7 Oct 2019 17:51:02 -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 23985 invoked by uid 89); 7 Oct 2019 17:51:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-30.4 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham version=3.3.1 spammy=HX-HELO:sk:mail-oi X-HELO: mail-oi1-f195.google.com Received: from mail-oi1-f195.google.com (HELO mail-oi1-f195.google.com) (209.85.167.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 17:51:00 +0000 Received: by mail-oi1-f195.google.com with SMTP id m16so12457799oic.5 for ; Mon, 07 Oct 2019 10:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/bRrYfYP6aJgNYCgh0CjjJxRS6tgixeDt1V8VCStX3c=; b=PxlS9GC7HsAdrsbEpeRvm/1TX+ZlVyxHDMnyo3q3M/m9GDt4uWJirBnWsSCyE0L4WS ZB+dizdaXPOW67MVZgBW7MPNBaYvF2KpsLwkoyEQaaHbSWaFPXqhTSi5ojwn2tsi8ajh +32u3XGu4NHViHKPiPStlXjbn0FMGXddvIXw1VZ+Jf3z7UaMmhsCnkncgDr1Lehp6vfq Qo9WKB7ASc6Xc93UFoeCFH7gH37nQq6vefOgOFLmUes4vkghBbH+5Qp4sIPZh4xr1u7G pfKXmHa93ogNYL5qLCDAT0gXtg3gUkIeuRWlYvauYbkHhTO9IxtUYt7GRviYyB5WwSFf BovA== MIME-Version: 1.0 References: <20191007173510.250346-1-cbiesinger@google.com> <4200cedb-f9ff-6041-acbd-991ea88fb502@simark.ca> In-Reply-To: <4200cedb-f9ff-6041-acbd-991ea88fb502@simark.ca> From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Mon, 07 Oct 2019 17:51:00 -0000 Message-ID: Subject: Re: [PATCH] Use gdb_static_assert in charset.c To: Simon Marchi Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00196.txt.bz2 On Mon, Oct 7, 2019 at 12:46 PM Simon Marchi 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 > > > > * 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