This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bounded Array Type?


On Wed, 22 Oct 2014, Martin Uecker wrote:

> 
> 
> Sorry for bringing this up again, but this could work:
> 
> void foo(int x, int (*s)[x])
> {
>         (*s)[x] = 1;	// <- undefined behaviour

Yes, I believe that's undefined (even if the array is part of a larger 
object, as the same principle as "An array subscript is out of range, even 
if an object is apparently accessible with the given subscript (as in the 
lvalue expression a[1][7] given the declaration int a[4][5]) (6.5.6)." 
(Annex J) applies).

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]