From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 95B773858027 for ; Wed, 19 Oct 2022 14:58:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95B773858027 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.95,196,1661846400"; d="scan'208";a="85039462" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 19 Oct 2022 06:58:04 -0800 IronPort-SDR: Z79wLa6uNSiyB2SbDRpdOaCD+0MJOQv1USNBGN47DRoYY6THj0yXGh+Rz8oqaO2Vkxwhal7L8X EiubR4rxN65F29p9pF5n/MEn1EL/8fJUgLNXOAIYbU8uKX4sSDcMgQbgro40yLIO6EznUGUD5d R2aKJoTc6irdSjNgiofoHeHwoRGSyktZipqR7lNqacqawKvLdtBs/p1Dwh3HQZ1FWzAmAkWAV2 3C1fP09EA0ZuGj2rtAZzpVEs2CMWpXOd/E9voBExDvJMk+//8IDnMOCzjfpqdHIHi8lQ5/hGN8 7Bk= Date: Wed, 19 Oct 2022 14:57:59 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Jakub Jelinek CC: Subject: Re: [committed] c: C2x enums wider than int [PR36113] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3110.6 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 19 Oct 2022, Jakub Jelinek wrote: > > +/* Likewise, for overflow from long to long long. */ > > +#if __LONG_LONG_MAX__ > __LONG_MAX__ > > +enum e5 { e5a = __LONG_MAX__, > > + e5b, e5c, e5d = ((typeof (e5b)) -1) < 0, > > + e5e = (unsigned long) -1, > > + e5f, e5g = ((typeof (e5e)) -1) > 0, > > + TYPE_CHECK (e5a, long), TYPE_CHECK (e5e, unsigned long) }; > > This fails on x86_64-linux with -m32 and I assume most other 32-bit > targets, it works with > TYPE_CHECK (e5a, int), TYPE_CHECK (e5e, unsigned long) }; > Haven't checked in detail, but if int and long have the same bitsize, > doesn't __LONG_MAX__ fit into int and so this new handling of large > enumerators doesn't apply? > Can we just change that unconditionally, or shall it be conditional > on #if __LONG_MAX__ > __INT_MAX__ (then use long, otherwise int)? I think the type checked for e5a should be conditional on __LONG_MAX__ > __INT_MAX__; everything else there should be OK regardless. -- Joseph S. Myers joseph@codesourcery.com