From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 90A08385E005 for ; Mon, 7 Sep 2020 00:56:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 90A08385E005 Received: by mail-pj1-x102e.google.com with SMTP id a9so2643028pjg.1 for ; Sun, 06 Sep 2020 17:56:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bcA+4Q0Qw6V3X7G4cJW9EMyS1e0SRtl8ErU4wtJ76vI=; b=tZdtdXW133bHTvu7ZO33iK+qvmYAjwW/ZSpCMFWmqUj9fYd+9JulFIIxQ/gOApkCwn kG7aJaAs1TZ5HQL1lQx7BYIBc7ptp+KcbzXZsidfIZRYZuTEFpDtOlF7vxZstliPsp8q UXQTaF0qJkdVFM4iQsuL7tmgVDIL29vOsqiBHcIlLLXfYEo8yQqKuTj4FRyK1BmwBjWy eUNfMUqMx7qIR6COUlf2OsMWKmOVfitZfs4jJyiAiMlo8Pum+y8CCigF7XkSH2jtlxa5 qF88gpRbVaeAStJYvBqW9xbtUc9RMraTKUfNNtkCZi39hM5tAFXM2EFXXAHQf5yiWGbA Knng== X-Gm-Message-State: AOAM533nCuLkMUCnk+s6Pm8Y5RZ6fngxDzFSVfMDEhQbBkUtbpGlUDuU aXbm8/1XtRoeZ154HhfpiHE= X-Google-Smtp-Source: ABdhPJx9d54uO8c4jwefUZdmu8xM4F1Qu8XWkI4xuJqpn8DI1J5rHOAdEYzqSwx0vbdMdiJnE8bH/Q== X-Received: by 2002:a17:90a:ec05:: with SMTP id l5mr19148602pjy.172.1599440215702; Sun, 06 Sep 2020 17:56:55 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id p11sm11629446pgh.80.2020.09.06.17.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 17:56:54 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id D361686DA4; Mon, 7 Sep 2020 10:26:50 +0930 (ACST) Date: Mon, 7 Sep 2020 10:26:50 +0930 From: Alan Modra To: Iain Buclaw Cc: gcc-patches@gcc.gnu.org, Ian Lance Taylor Subject: Re: ubsan: d-demangle.c:214 signed integer overflow Message-ID: <20200907005650.GW15695@bubble.grove.modra.org> References: <20200903130116.GQ15695@bubble.grove.modra.org> <1599163400.8r2ly1k30n.astroid@galago.none> <20200904005939.GR15695@bubble.grove.modra.org> <1599207109.qqwjbgoeso.astroid@galago.none> <20200904133403.GV15695@bubble.grove.modra.org> <1599234463.wegd8hf5fw.astroid@galago.none> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1599234463.wegd8hf5fw.astroid@galago.none> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2020 00:56:57 -0000 On Fri, Sep 04, 2020 at 06:23:10PM +0200, Iain Buclaw wrote: > If we're already using limits.h, I guess it should be fine to also add > > #define UINT_MAX ((unsigned) ~0U) Yes, except that I'll use the simpler fall-back #define UINT_MAX (~0U) The habit of using a cast for unsigned constants dates back to K&R C where a U suffix was not valid. For example, from libiberty/strtol.c #define ULONG_MAX ((unsigned long)(~0L)) Since the code uses ISO/ANSI C features such as prototypes I think we're OK with a U suffix. And if there's something I'm missing then #define UINT_MAX ((unsigned) ~0) would be correct for K&R. > I'll leave it to your judgement on that though. > > Other than that, OK from me. Do I need an OK from Ian too? -- Alan Modra Australia Development Lab, IBM