From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22935 invoked by alias); 16 Jan 2019 20:02:34 -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 22908 invoked by uid 89); 16 Jan 2019 20:02:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=BAYES_00,BODY_8BITS,GARBLED_BODY,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1694, HContent-Transfer-Encoding:8bit X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Jan 2019 20:02:32 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id x0GK2OWj020853 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 16 Jan 2019 15:02:29 -0500 Received: by simark.ca (Postfix, from userid 112) id 665851E7B9; Wed, 16 Jan 2019 15:02:24 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 827B71E4A3; Wed, 16 Jan 2019 15:02:23 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 16 Jan 2019 20:02:00 -0000 From: Simon Marchi To: =?UTF-8?Q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB_=D0=9A=D1=80=D1=8E=D0=BA?= =?UTF-8?Q?=D0=BE=D0=B2?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Do not expand macros to 'defined' In-Reply-To: References: Message-ID: <4943ce6216667607c40b630ecba6a4d1@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00381.txt.bz2 On 2019-01-16 01:34, Павел Крюков wrote: > Expanding a macro which contains 'defined' PP keyword is UB. > > sim/common/Changelog: > 2019-01-16 Pavel I. Kryukov > > * sim-arange.c: eliminate DEFINE_NON_INLINE_P > --- > sim/common/sim-arange.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/sim/common/sim-arange.c b/sim/common/sim-arange.c > index 6373b742ce8..b3488ab564a 100644 > --- a/sim/common/sim-arange.c > +++ b/sim/common/sim-arange.c > @@ -32,10 +32,7 @@ along with this program. If not, see > . */ > #include > #endif > > -#define DEFINE_INLINE_P (! defined (SIM_ARANGE_C_INCLUDED)) > -#define DEFINE_NON_INLINE_P defined (SIM_ARANGE_C_INCLUDED) > - > -#if DEFINE_NON_INLINE_P > +#ifdef SIM_ARANGE_C_INCLUDED > > /* Insert a range. */ > > @@ -280,9 +277,7 @@ sim_addr_range_delete (ADDR_RANGE *ar, > address_word start, address_word end) > build_search_tree (ar); > } > > -#endif /* DEFINE_NON_INLINE_P */ > - > -#if DEFINE_INLINE_P > +#else /* SIM_ARANGE_C_INCLUDED */ > > SIM_ARANGE_INLINE int > sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr) > @@ -301,4 +296,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word > addr) > return 0; > } > > -#endif /* DEFINE_INLINE_P */ > +#endif /* SIM_ARANGE_C_INCLUDED */ The patch LGTM, I agree these macros are not really needed. But I am confused, does this actually fix your c++ build? You mentioned you were using g++ (and therefore cpp), which supposedly can handle this fine: https://gcc.gnu.org/onlinedocs/cpp/Defined.html If so, what did the error look like? Simon