public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>,
	Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: bug in roundup(3) from <sys/param.h>
Date: Tue, 17 Jan 2023 21:13:15 +0100	[thread overview]
Message-ID: <9d821d48-8ea9-7af6-10c7-0fc222437191@gmail.com> (raw)
In-Reply-To: <59e67ba9-a379-16e9-3300-8f7d6114bf5c@cs.ucla.edu>


[-- Attachment #1.1: Type: text/plain, Size: 961 bytes --]

Hi Paul!

On 1/17/23 21:11, Paul Eggert wrote:
> On 1/17/23 11:16, Wilco Dijkstra via Libc-alpha wrote:
>> So it seems best to state it only works on unsigned values (with y > 0 since 
>> division
>> by zero is undefined behaviour of course) and it's implementation defined whether
>> overflow wraps or saturates.
> 
> roundup works just fine on signed integers. Although x should be nonnegative and 
> y should be positive, there's no requirement that either x or y must be unsigned.
> 
> This sort of thing matters in the C style I prefer nowadays, which is to use 
> types like ptrdiff_t and idx_t instead of size_t, so that I can optionally 
> enable runtime overflow checking that works.

That's fair; I'll clarify, and anyway, will post the manual page for review 
before pushing.

If you happen to know od any other use cases for this function, it might be 
interesting.

Cheers,

Alex

-- 
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-01-17 20:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 19:16 Wilco Dijkstra
2023-01-17 19:50 ` Alejandro Colomar
2023-01-17 20:11 ` Paul Eggert
2023-01-17 20:13   ` Alejandro Colomar [this message]
2023-01-17 20:24     ` [RFC] roundup.3: New page documenting roundup(3) (was: bug in roundup(3) from <sys/param.h>) Alejandro Colomar
2023-01-17 21:53       ` Paul Eggert
2023-01-17 22:29         ` Alejandro Colomar
  -- strict thread matches above, loose matches on Subject: below --
2023-01-16 20:46 bug in roundup(3) from <sys/param.h> Alejandro Colomar
2023-01-17  2:22 ` Alejandro Colomar
2023-01-17 14:55 ` Adhemerval Zanella Netto

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=9d821d48-8ea9-7af6-10c7-0fc222437191@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.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).