Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Xi, On Sat, Jul 06, 2024 at 10:24:16AM GMT, Xi Ruoyao wrote: > On Sat, 2024-07-06 at 00:02 +0200, Alejandro Colomar wrote: > > That's precisely the case with strtol(3): it doesn't access any objects > > through *endptr, and so that pointer need not be restrict. > > > > Then, nptr is a read-onl

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
On Sat, Jul 06, 2024 at 08:10:28AM GMT, Alejandro Colomar wrote: > Hi Xi, > > On Sat, Jul 06, 2024 at 10:24:16AM GMT, Xi Ruoyao wrote: > > On Sat, 2024-07-06 at 00:02 +0200, Alejandro Colomar wrote: > > > That's precisely the case with strtol(3): it doesn't access any objects > > > through *endptr

[[gnu::null_terminated_string_arg(1)]] on strtol(1) (was: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like) functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Xi, On Sat, Jul 06, 2024 at 10:39:41AM GMT, Xi Ruoyao wrote: > BTW among your list: > > > > [[gnu::access(read_only, 1)]] > > > [[gnu::access(write_only, 2)]] > > > [[gnu::leaf]] > > > [[gnu::nothrow]] > > > [[gnu::null_terminated_string_arg(1)]] > > IMO we should add these access attributes,

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Xi Ruoyao via Gcc
On Sat, 2024-07-06 at 10:24 +0800, Xi Ruoyao wrote: > On Sat, 2024-07-06 at 00:02 +0200, Alejandro Colomar wrote: > > That's precisely the case with strtol(3): it doesn't access any objects > > through *endptr, and so that pointer need not be restrict. > > > > Then, nptr is a read-only pointer, so

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Xi Ruoyao via Gcc
On Sat, 2024-07-06 at 00:02 +0200, Alejandro Colomar wrote: > That's precisely the case with strtol(3): it doesn't access any objects > through *endptr, and so that pointer need not be restrict. > > Then, nptr is a read-only pointer, so is doesn't matter either if it's > accessed or not. Restrict

Re: [RFC] MAINTAINERS: require a BZ account field

2024-07-05 Thread Sam James via Gcc
Richard Sandiford writes: > Sam James via Gcc writes: >> Hi! >> >> This comes up in #gcc on IRC every so often, so finally >> writing an RFC. >> > [...] >> TL;DR: The proposal is: >> >> 1) MAINTAINERS should list a field containing either the gcc.gnu.org >> email in full, or their gcc username (

gcc-13-20240705 is now available

2024-07-05 Thread GCC Administrator via Gcc
Snapshot gcc-13-20240705 is now available on https://gcc.gnu.org/pub/gcc/snapshots/13-20240705/ and on various mirrors, see https://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 13 git branch with the following options: git://gcc.gnu.org/git/gcc.git branch

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
On Sat, Jul 06, 2024 at 12:02:06AM GMT, Alejandro Colomar wrote: > Hi Jonathan, > > On Fri, Jul 05, 2024 at 10:39:52PM GMT, Jonathan Wakely wrote: > > On Fri, 5 Jul 2024 at 21:55, Alejandro Colomar wrote: > > > > > > On Fri, Jul 05, 2024 at 09:28:46PM GMT, Jonathan Wakely wrote: > > > > > If we m

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Jonathan, On Fri, Jul 05, 2024 at 10:39:52PM GMT, Jonathan Wakely wrote: > On Fri, 5 Jul 2024 at 21:55, Alejandro Colomar wrote: > > > > On Fri, Jul 05, 2024 at 09:28:46PM GMT, Jonathan Wakely wrote: > > > > If we marked endptr as "write_only" (which it might already > > > > be) then a future

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 21:55, Alejandro Colomar wrote: > > On Fri, Jul 05, 2024 at 09:28:46PM GMT, Jonathan Wakely wrote: > > > If we marked endptr as "write_only" (which it might already > > > be) then a future warning mechanism for -Wrestrict could > > > ignore the content of *endptr. > > > > > >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
On Fri, Jul 05, 2024 at 09:28:46PM GMT, Jonathan Wakely wrote: > > If we marked endptr as "write_only" (which it might already > > be) then a future warning mechanism for -Wrestrict could > > ignore the content of *endptr. > > > That seems more useful. Add semantic information instead of taking i

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
On Fri, Jul 05, 2024 at 09:28:46PM GMT, Jonathan Wakely wrote: > On Fri, 5 Jul 2024 at 21:26, Martin Uecker wrote: > > > > Am Freitag, dem 05.07.2024 um 21:28 +0200 schrieb Alejandro Colomar: > > > > ... > > > > > > > > Showing that you can contrive a case where a const char* restrict and > > > >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Ben Boeckel via Gcc
On Fri, Jul 05, 2024 at 22:15:44 +0200, Emanuele Torre via Gcc wrote: > That is 6.7.3.1p3: > > > > In what follows, a pointer expression E is said to be based on object P > if (at some sequence point in the execution of B prior to the > evaluation of E) modifying P to point to a copy of

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 21:26, Martin Uecker wrote: > > Am Freitag, dem 05.07.2024 um 21:28 +0200 schrieb Alejandro Colomar: > > ... > > > > > > Showing that you can contrive a case where a const char* restrict and > > > > char** restrict can alias doesn't mean there's a problem with strtol. > > > >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Martin Uecker via Gcc
Am Freitag, dem 05.07.2024 um 21:28 +0200 schrieb Alejandro Colomar: ... > > > > Showing that you can contrive a case where a const char* restrict and > > > char** restrict can alias doesn't mean there's a problem with strtol. > > > > I think his point is that a const char* restrict and somethin

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Emanuele Torre via Gcc
On Fri, Jul 05, 2024 at 08:52:30PM +0100, Jonathan Wakely wrote: > On Fri, 5 Jul 2024 at 20:47, Alejandro Colomar wrote: > > > > Here's 153 in N3047: > > That draft is nearly two years old. > > > > > 153) An implementation can delay the choice of which integer type until > > all enumeration

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Jonathan, On Fri, Jul 05, 2024 at 08:52:30PM GMT, Jonathan Wakely wrote: > > > > > > > It **shouldn't**. strtol will only violate restrict if it's > > > > > > > wrongly > > > > > > > implemented, or something dumb is done like "strtol((const char*) > > > > > > > &p, > > > > > > > &p, 0)". >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 20:47, Alejandro Colomar wrote: > > Hi Jonathan, > > On Fri, Jul 05, 2024 at 08:38:15PM GMT, Jonathan Wakely wrote: > > On Fri, 5 Jul 2024 at 20:28, Alejandro Colomar wrote: > > > > > > Hi, > > > > > > On Fri, Jul 05, 2024 at 06:30:50PM GMT, Martin Uecker wrote: > > > > Am F

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Jonathan, On Fri, Jul 05, 2024 at 08:38:15PM GMT, Jonathan Wakely wrote: > On Fri, 5 Jul 2024 at 20:28, Alejandro Colomar wrote: > > > > Hi, > > > > On Fri, Jul 05, 2024 at 06:30:50PM GMT, Martin Uecker wrote: > > > Am Freitag, dem 05.07.2024 um 17:24 +0100 schrieb Jonathan Wakely: > > > > On

[WG14] Request for document number; strtol restrictness

2024-07-05 Thread Alejandro Colomar via Gcc
Hi, I have a paper for removing restrict from the first parameter of strtol(3) et al. The title is strtol(3) et al. should’t have a restricted first parameter. If it helps, I already have a draft of the paper, which I attach (both the PDF, and the man(7) source). Cheers, Alex --

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 20:28, Alejandro Colomar wrote: > > Hi, > > On Fri, Jul 05, 2024 at 06:30:50PM GMT, Martin Uecker wrote: > > Am Freitag, dem 05.07.2024 um 17:24 +0100 schrieb Jonathan Wakely: > > > On Fri, 5 Jul 2024 at 17:02, Xi Ruoyao via Gcc wrote: > > > > > > > > On Fri, 2024-07-05 at 1

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi, On Fri, Jul 05, 2024 at 06:30:50PM GMT, Martin Uecker wrote: > Am Freitag, dem 05.07.2024 um 17:24 +0100 schrieb Jonathan Wakely: > > On Fri, 5 Jul 2024 at 17:02, Xi Ruoyao via Gcc wrote: > > > > > > On Fri, 2024-07-05 at 17:53 +0200, Alejandro Colomar wrote: > > > > At least, I hope there's

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
On Fri, Jul 05, 2024 at 06:32:26PM GMT, Alejandro Colomar wrote: > Hi Xi, > > On Fri, Jul 05, 2024 at 11:55:05PM GMT, Xi Ruoyao wrote: > > On Fri, 2024-07-05 at 17:23 +0200, Alejandro Colomar wrote: > > > > strtol does have  a "char * restrict * restrict" though, so the > > > > situation is differ

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Sam James via Gcc
Jonathan Wakely via Gcc writes: > On Fri, 5 Jul 2024 at 17:02, Xi Ruoyao via Gcc wrote: >> >> On Fri, 2024-07-05 at 17:53 +0200, Alejandro Colomar wrote: >> > At least, I hope there's consensus that while current GCC doesn't warn >> > about this, ideally it should, which means it should warn for

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Xi, On Fri, Jul 05, 2024 at 11:55:05PM GMT, Xi Ruoyao wrote: > On Fri, 2024-07-05 at 17:23 +0200, Alejandro Colomar wrote: > > > strtol does have  a "char * restrict * restrict" though, so the > > > situation is different.   A "char **" and a "const char *" > > > shouldn't alias anyway. > > >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Martin Uecker via Gcc
Am Freitag, dem 05.07.2024 um 17:24 +0100 schrieb Jonathan Wakely: > On Fri, 5 Jul 2024 at 17:02, Xi Ruoyao via Gcc wrote: > > > > On Fri, 2024-07-05 at 17:53 +0200, Alejandro Colomar wrote: > > > At least, I hope there's consensus that while current GCC doesn't warn > > > about this, ideally it

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 17:02, Xi Ruoyao via Gcc wrote: > > On Fri, 2024-07-05 at 17:53 +0200, Alejandro Colomar wrote: > > At least, I hope there's consensus that while current GCC doesn't warn > > about this, ideally it should, which means it should warn for valid uses > > of strtol(3), which mean

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Richard Earnshaw (lists) via Gcc
On 05/07/2024 17:11, Jonathan Wakely via Gcc wrote: > On Fri, 5 Jul 2024 at 16:54, Alejandro Colomar via Gcc > wrote: >> At least, I hope there's consensus that while current GCC doesn't warn >> about this, ideally it should, which means it should warn for valid uses >> of strtol(3), which means

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Xi Ruoyao via Gcc
On Sat, 2024-07-06 at 00:01 +0800, Xi Ruoyao wrote: > On Fri, 2024-07-05 at 17:53 +0200, Alejandro Colomar wrote: > > At least, I hope there's consensus that while current GCC doesn't warn > > about this, ideally it should, which means it should warn for valid uses > > of strtol(3), which means str

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 16:54, Alejandro Colomar via Gcc wrote: > At least, I hope there's consensus that while current GCC doesn't warn > about this, ideally it should, which means it should warn for valid uses > of strtol(3), which means strtol(3) should be fixed, in all of ISO, > POSIX, and glibc

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Martin Uecker via Gcc
Am Freitag, dem 05.07.2024 um 17:53 +0200 schrieb Alejandro Colomar: > Hi Martin, > > On Fri, Jul 05, 2024 at 05:34:55PM GMT, Martin Uecker wrote: > > > I've written functions that more closely resemble strtol(3), to show > > > that in the end they all share the same issue regarding const-ness: >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Xi Ruoyao via Gcc
On Fri, 2024-07-05 at 17:53 +0200, Alejandro Colomar wrote: > At least, I hope there's consensus that while current GCC doesn't warn > about this, ideally it should, which means it should warn for valid uses > of strtol(3), which means strtol(3) should be fixed, in all of ISO, > POSIX, and glibc.

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread LIU Hao via Gcc
在 2024-07-05 23:23, Alejandro Colomar via Gcc 写道: Hi Martin, On Fri, Jul 05, 2024 at 05:02:15PM GMT, Martin Uecker wrote: But when the thing gets non-trivial, as in strtol(3), GCC misses the -Wrestrict diagnostic, as reported in A pointer to `char` can alias any object, so in theory one could

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Xi Ruoyao via Gcc
On Fri, 2024-07-05 at 17:23 +0200, Alejandro Colomar wrote: > > strtol does have  a "char * restrict * restrict" though, so the > > situation is different.   A "char **" and a "const char *" > > shouldn't alias anyway. > > Pedantically, it is actually declared as 'char **restrict' (the inner > on

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Martin, On Fri, Jul 05, 2024 at 05:34:55PM GMT, Martin Uecker wrote: > > I've written functions that more closely resemble strtol(3), to show > > that in the end they all share the same issue regarding const-ness: (Above I meant s/const/restrict/) > > > > $ cat d.c > > int d(const c

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Martin Uecker via Gcc
Am Freitag, dem 05.07.2024 um 17:23 +0200 schrieb Alejandro Colomar: > Hi Martin, > > On Fri, Jul 05, 2024 at 05:02:15PM GMT, Martin Uecker wrote: > > > But when the thing gets non-trivial, as in strtol(3), GCC misses the > > > -Wrestrict diagnostic, as reported in > > >

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
Hi Martin, On Fri, Jul 05, 2024 at 05:02:15PM GMT, Martin Uecker wrote: > > But when the thing gets non-trivial, as in strtol(3), GCC misses the > > -Wrestrict diagnostic, as reported in > > . > > > > Let's write a reproducer by altering the du

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Martin Uecker via Gcc
Am Freitag, dem 05.07.2024 um 16:37 +0200 schrieb Alejandro Colomar via Gcc: > [CC += linux-man@, since we're discussing an API documented there, and > the manual page would also need to be updated] > > Hi Xi, Jakub, > > On Fri, Jul 05, 2024 at 09:38:21PM GMT, Xi Ruoyao wrote: > > On Fri, 2024-

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
[CC += linux-man@, since we're discussing an API documented there, and the manual page would also need to be updated] Hi Xi, Jakub, On Fri, Jul 05, 2024 at 09:38:21PM GMT, Xi Ruoyao wrote: > On Fri, 2024-07-05 at 15:03 +0200, Alejandro Colomar wrote: > > ISO C specifies these APIs as accepting

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Jakub Jelinek via Gcc
On Fri, Jul 05, 2024 at 09:38:21PM +0800, Xi Ruoyao via Gcc wrote: > On Fri, 2024-07-05 at 15:03 +0200, Alejandro Colomar wrote: > > ISO C specifies these APIs as accepting a restricted pointer in their > > first parameter: > > > > $ stdc c99 strtol > > long int strtol(const char *restrict nptr, c

Re: [PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Xi Ruoyao via Gcc
On Fri, 2024-07-05 at 15:03 +0200, Alejandro Colomar wrote: > ISO C specifies these APIs as accepting a restricted pointer in their > first parameter: > > $ stdc c99 strtol > long int strtol(const char *restrict nptr, char **restrict endptr, int base); > $ stdc c11 strtol > long int strtol(const c

[PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

2024-07-05 Thread Alejandro Colomar via Gcc
ISO C specifies these APIs as accepting a restricted pointer in their first parameter: $ stdc c99 strtol long int strtol(const char *restrict nptr, char **restrict endptr, int base); $ stdc c11 strtol long int strtol(const char *restrict nptr, char **restrict endptr, int base); However, it should

Re: GCC Download Issue

2024-07-05 Thread Jonathan Wakely via Gcc
On Fri, 5 Jul 2024 at 10:49, Dinesh M via Gcc wrote: > > Hi Gcc Team, > > I am trying to download gcc compiler but didn't download the compiler Please note this quyestion belongs on the gcc-help list, not the gcc list. Why didn't you download it? What did you try? What didn't work? > please giv

GCC Download Issue

2024-07-05 Thread Dinesh M via Gcc
Hi Gcc Team, I am trying to download gcc compiler but didn't download the compiler please give me solution, how to do download this? Regards, Dinesh M