Re: Spurious warning for zero-sized array parameters to a function

2022-12-09 Thread Alejandro Colomar via Gcc
On 12/9/22 21:19, Alejandro Colomar wrote: Hi Martin, On 12/9/22 21:04, mse...@gmail.com wrote: Most of these warnings are designed to find simple mistakes in common use cases so "tricky," unusual, or otherwise unexpected code is likely to lead to surprises.  This warning expects that in c

Re: Spurious warning for zero-sized array parameters to a function

2022-12-09 Thread Alejandro Colomar via Gcc
Hi Martin, On 12/9/22 21:04, mse...@gmail.com wrote: Most of these warnings are designed to find simple mistakes in common use cases so "tricky," unusual, or otherwise unexpected code is likely to lead to surprises. This warning expects that in calls to a function, every parameter declared u

Re: Spurious warning for zero-sized array parameters to a function

2022-12-09 Thread msebor--- via Gcc
> On Dec 6, 2022, at 9:22 AM, Alejandro Colomar via Gcc wrote: > > Hi! > > In the following function, past_end is a pointer to one-past-the-end of the > array. Holding such a pointer is legal in C. I use it as a sentinel value > that helps (1) avoid overrunning the buffer, and (2) detect tr

Re: Spurious warning for zero-sized array parameters to a function

2022-12-09 Thread Alejandro Colomar via Gcc
Hi Richard, On 12/7/22 09:17, Richard Biener wrote: [...] The warnings are invalid. While it's true that I'm referencing a pointer of size 0, it's false that I'm "accessing 1 byte" in that region. I guess this is all about the bogus design of 'static' in ISO C, where you can have an array par

Re: Spurious warning for zero-sized array parameters to a function

2022-12-07 Thread Richard Biener via Gcc
On Tue, Dec 6, 2022 at 5:22 PM Alejandro Colomar via Gcc wrote: > > Hi! > > In the following function, past_end is a pointer to one-past-the-end of the > array. Holding such a pointer is legal in C. I use it as a sentinel value > that > helps (1) avoid overrunning the buffer, and (2) detect tru

Spurious warning for zero-sized array parameters to a function

2022-12-06 Thread Alejandro Colomar via Gcc
Hi! In the following function, past_end is a pointer to one-past-the-end of the array. Holding such a pointer is legal in C. I use it as a sentinel value that helps (1) avoid overrunning the buffer, and (2) detect truncation. I mark it as having a size of [0], which clearly states that it c