Re: [RFC] [PATCH] Add __array_size keyword

2016-02-23 Thread Stuart Brady
On Wed, Feb 17, 2016 at 12:29:34AM +, Stuart Brady wrote: > > - should __array_size (b) be an integer constant (size_t)2, or should it > > be non-constant (size_t)2 because the argument is a VLA (albeit a VLA > > whose top-level dimension is an integer constant expression)? > > Ouch. I woul

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-16 Thread Stuart Brady
On Tue, Feb 16, 2016 at 11:35:24PM +, Joseph Myers wrote: > What's right is: > > * In cases where it should return an integer constant (you've said that's > when the argument is not a VLA, as for sizeof), there should be no > diagnostic. Right. > * In cases where it should not return an in

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-16 Thread Joseph Myers
On Tue, 16 Feb 2016, Stuart Brady wrote: > On Tue, Feb 16, 2016 at 11:10:08PM +, Joseph Myers wrote: > > It sets it to be null - but does it diagnose conversion from integer to > > pointer without a cast (it should do so if __array_size is not evaluating > > to an integer constant expression

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-16 Thread Stuart Brady
On Tue, Feb 16, 2016 at 11:10:08PM +, Joseph Myers wrote: > It sets it to be null - but does it diagnose conversion from integer to > pointer without a cast (it should do so if __array_size is not evaluating > to an integer constant expression, but not if it is evaluating to an > integer con

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-16 Thread Joseph Myers
On Tue, 16 Feb 2016, Stuart Brady wrote: > > For whether arguments are evaluated, you need __array_size with arguments > > that have side effects, and then test whether those side effects occurred. > > For whether results are integer constant expressions, you can test e.g. > > whether __array_

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-16 Thread Stuart Brady
On Mon, Feb 15, 2016 at 03:51:43PM +, Stuart Brady wrote: > On Mon, Feb 15, 2016 at 03:05:36PM +0100, Marek Polacek wrote: > > On Sat, Feb 13, 2016 at 03:16:49AM +, Stuart Brady wrote: > > > For a hypothetical change to the C standard itself, I think one might use > > > the name "_ArraySize

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-16 Thread Stuart Brady
On Mon, Feb 15, 2016 at 11:11:54PM +, Joseph Myers wrote: > On Sat, 13 Feb 2016, Stuart Brady wrote: > > > So in other words, adapting all of the sizeof tests would be appropriate, > > and sizeof tests for non-array types would change from expected passes to > > expected failures? > > It's no

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-15 Thread Joseph Myers
On Sat, 13 Feb 2016, Stuart Brady wrote: > > Critical issues to define and cover thoroughly in tests include the > > rules for when operands of sizeof are evaluated, as adapted > > appropriately for this keyword, and for when it returns various kinds > > of constants. > > So in other words, adapt

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-15 Thread Stuart Brady
On Mon, Feb 15, 2016 at 03:05:36PM +0100, Marek Polacek wrote: > On Sat, Feb 13, 2016 at 03:16:49AM +, Stuart Brady wrote: > > I will look into submitting a PR for this properly soon, but will not > > mind if someone wants to take this task upon themselves instead, > > especially as we are into

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-15 Thread Marek Polacek
On Sat, Feb 13, 2016 at 03:16:49AM +, Stuart Brady wrote: > As a brief aside, I do get an ICE with the following source, without any > modifications of my own: > >int bar() { return foo(); } >void baz(int c[foo()]) { return; } > > I will look into submitting a PR for this properly soo

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-12 Thread Stuart Brady
On Thu, Feb 11, 2016 at 10:41:02PM +, Joseph Myers wrote: > For proposed features, I find documentation and testcases of much more > value than the rest of the implementation. I can see the logic of that. This is the part that I find a little tricky, so please bear with me here. > Critical

Re: [RFC] [PATCH] Add __array_size keyword

2016-02-11 Thread Joseph Myers
On Thu, 11 Feb 2016, Stuart Brady wrote: > Documentation and test code are currently absent from the patch, but I For proposed features, I find documentation and testcases of much more value than the rest of the implementation. Critical issues to define and cover thoroughly in tests include th