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,752 of 243,242   
   Paul J. Lucas to highcrew   
   Re: On Undefined Behavior   
   03 Jan 26 17:10:22   
   
   From: paul@lucasmail.org   
      
   On 1/1/26 1:54 PM, highcrew wrote:   
      
   > For the lazy, I report it here:   
   >   
   >    int table[4] = {0};   
   >    int exists_in_table(int v)   
   >    {   
   >        // return true in one of the first 4 iterations   
   >        // or UB due to out-of-bounds access   
   >        for (int i = 0; i <= 4; i++) {   
   >            if (table[i] == v) return 1;   
   >        }   
   >        return 0;   
   >    }   
      
   This particular example is explained is several places, e.g.:   
      
   https://devblogs.microsoft.com/oldnewthing/20140627-00/?p=633   
      
   Perhaps a slightly better explanation of the same example:   
      
   https://medium.com/@pauljlucas/undefined-behavior-in-c-and-c-f30844f20e2a   
      
   - Paul   
      
   --- 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