[Bug c++/107735] Inconsistent error messages for std::array out of bound due to taking the address of one-past-the-end is valid

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 18 00:49:28 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107735

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > I wonder if this is because doing 
> > constexpr const int *v1 = &array[3];
> > 
> > is valid and well defined.
> 
> It's not, but &array.data()[3] is.
> 
> I agree that's probably the reason for the different diagnostics.

Interesting because both GCC and clang accept "constexpr const int *v1 =
&array[3];" though.


More information about the Gcc-bugs mailing list