public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Iain Buclaw <ibuclaw@gdcproject.org>
Cc: gcc-patches@gcc.gnu.org, Ian Lance Taylor <ian@airs.com>
Subject: Re: ubsan: d-demangle.c:214 signed integer overflow
Date: Mon, 7 Sep 2020 10:26:50 +0930	[thread overview]
Message-ID: <20200907005650.GW15695@bubble.grove.modra.org> (raw)
In-Reply-To: <1599234463.wegd8hf5fw.astroid@galago.none>

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

  reply	other threads:[~2020-09-07  0:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 13:01 Alan Modra
2020-09-03 21:02 ` Iain Buclaw
2020-09-04  0:59   ` Alan Modra
2020-09-04 11:22     ` Iain Buclaw
2020-09-04 13:34       ` Alan Modra
2020-09-04 16:23         ` Iain Buclaw
2020-09-07  0:56           ` Alan Modra [this message]
2020-09-07 16:17             ` Iain Buclaw
2020-09-07 17:46               ` Ian Lance Taylor
2020-11-13 19:04         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200907005650.GW15695@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ian@airs.com \
    --cc=ibuclaw@gdcproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).