From: Collin Funk <collin.funk1@gmail.com>
To: "Sertonix" <sertonix@posteo.net>
Cc: "Alejandro Colomar" <alx@kernel.org>, <linux-man@vger.kernel.org>
Subject: Re: swab.3: mention UB when from and to overlap
Date: Sat, 11 Oct 2025 15:40:34 -0700 [thread overview]
Message-ID: <875xclm599.fsf@gmail.com> (raw)
In-Reply-To: <DDFUAR7OXZ38.3SGS6R89CDDMD@posteo.net>
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
"Sertonix" <sertonix@posteo.net> writes:
> The current swab.3 page doesn't seem to mention anything about what
> happens when from and to overlap. In POSIX any overlap is UB.
>
> glibc handles cases when from == to but it will choke when for example
> from == to+1. I am uncertain if from == to is meant to be a feature.
>
> If it is, would it be possible to mention that overlap is only safe when
> from == to and it's glibc (not eg. musl)? If it's not intended would it
> be possible to include the same information as in POSIX?
The prototype uses restrict for both pointers which is how you tell the
C compiler that two objects will not overlap.
But maybe it is better to be friendly to those new to see and state it
explicitly? Alex will know better than I.
Collin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2025-10-11 22:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-11 22:18 swab.3: mention UB when from and to overlap Sertonix
2025-10-11 22:40 ` Collin Funk [this message]
2025-10-12 0:02 ` Alejandro Colomar
2025-10-12 10:42 ` Sertonix
2025-10-12 11:04 ` Alejandro Colomar
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=875xclm599.fsf@gmail.com \
--to=collin.funk1@gmail.com \
--cc=alx@kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=sertonix@posteo.net \
/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