home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,995 of 243,242   
   Pierre Asselin to Michael S   
   Re: UB or not UB? was: On Undefined Beha   
   13 Jan 26 20:19:50   
   
   From: pa@see.signature.invalid   
      
   Michael S  wrote:   
      
   > > There is amplification in Annex J.2, roughly three pages   
   > > after the start of J.2.  You can search for "an array   
   > > subscript is out of range", where there is a clarifying   
   > > example.   
      
   > I see the following text:   
   > "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.7)."   
      
      
   In numerical analysis it is often useful to flatten   
   multidimensional arrays. For example,   
      
       void initialize(int table[4][4])   
       {   
   	int *flat= &table[0][0];   
   	for (int i= 0; i<16; i++) flat[i]= i;   
       }   
      
   Accessing table[0][i] would have been UB according to appendix J.   
   Is going through flat[i] UB as well? Probably, and that's a shame.   
      
   --   
   pa at panix dot com   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca