From: jameskuyper@alumni.caltech.edu   
      
   On 2026-01-13 04:31, Michael S wrote:   
   > On Mon, 12 Jan 2026 21:09:25 -0500   
   > "James Russell Kuyper Jr." wrote:   
   >   
   >> On 2026-01-12 15:02, Scott Lurndal wrote:   
   >>> Michael S writes:   
   >>>> On Mon, 12 Jan 2026 15:58:15 +0000   
   >>>> bart wrote:   
   >>>>> On 12/01/2026 14:28, Michael S wrote:   
   >> ...   
   >>>>>> struct bar1 {   
   >>>>>> int table[4];   
   >>>>>> int other_table[4];   
   >>>>>> };   
   >> ...   
   >>>>> So you want to deliberately read one element past the end because   
   >>>>> you know it will be the first element of other_table?   
   >>>>   
   >>>> Yes. I primarily want it for multi-dimensional arrays.   
   >>>   
   >>> So declare it as int table[4][4].   
   >>   
   >>   
   >> Note that this suggestion does not make the behavior defined. It is   
   >> undefined behavior to make dereference table[0]+4, and it is   
   >> undefined behavior to make any use of table[0]+5.   
   >>   
   >   
   > Pay attention that Scott didn't suggest that dereferencing table[0][4]   
   > in his example is defined.   
   > Not that I understood what he wanted to suggest :(   
   That's the difference - I did understand. In your struct, other_table is   
   not required to immediately follow table, but in the 2D array, table[0]   
   is guaranteed to follow table[1]. That's not sufficient to make   
   table[0][5] have defined behavior, but many people are unaware of that,   
   or are willing to take the chance.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|