On Thu, Mar 12, 2020 at 2:40 PM Maciej Cencora via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Hi,

I propose to deprecate in C++23:
1) mixed pointer and array comparisons:
int a[2]; int b[2];
a == &b[0];

Why can't I compare those?  They're certainly not equal, the address of the first element, vs the address of the array?

 

2) array decl in func parameters:
void foo(int a[2]);

I think rather than having this removed, that it be strengthened... so if you pass a thing that's not an int[2] (const address of two integers), the compiler should notify you.
If the function wants specifically an array of N elements, and then uses that to condition the limits of loops used in itself, and then gets passed a much bigger thing...

void foo(int a[2]){ }  
int main( void ) { int a[5];    foo(a ); }  // should be an error I would think.

as differently typed as, (minus the struct namespace)
struct x{ int a[2] };
struct y{ int a[5] };

but with an anonymous struct type around them.

And really I think this would be an error too, because it's not a exactly sized array, but is a pointer to some-thing.
  int main( void ) { int a[2]; int *b = a;    foo(b ); }  

although a wildcard of any array like 

void bar( int a[] ) 

should still accept an array of any size, or a pointer...



In order to make C-style arrays behave like other aggregate types in C++26 or later (supported assignments, comparisons, passing and returning from functions)

Regards,
Maciej
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals