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 241,271 of 243,242   
   BGB to Kaz Kylheku   
   Re: Nice way of allocating flexible stru   
   08 Oct 25 22:25:06   
   
   From: cr88192@gmail.com   
      
   On 10/8/2025 8:39 PM, Kaz Kylheku wrote:   
   > On 2025-10-08, Keith Thompson  wrote:   
   >> But in addition to that, in Kaz's example, n is not a constant   
   >> expression, so `&(t.member-designator)` is not an address constant   
   >> and therefore `offsetof(S, A[n])` has undefined behavior.   
   >   
   > Great; I'd like to hear reasons to avoid it so I don't look foolish   
   > for having overlooked it for manytyears. :)   
   >   
   >> Every compiler I've tried handles this "correctly", and I tend to   
   >   
   > I'm sure I've seen foo.bar expressions on the right of an offsetof,   
   > but those still yield constants.   
   >   
      
   I think it is a case of, it is not required to work...   
      
   But, if the typical implementation is something like, say:   
   #define offsetof(T, M)  ((long)(&(((T *)0)->M)))   
      
   It is probably going to work without issue.   
      
   --- 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