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,827 of 243,242   
   Waldek Hebisch to highcrew   
   Re: function pointer question   
   06 Jan 26 14:50:47   
   
   From: antispam@fricas.org   
      
   highcrew  wrote:   
   > On 1/6/26 1:32 PM, Michael Sanders wrote:   
   >>      “Evaluate *foo, but explicitly discard its value.”   
   >>   
   >>      It is a cast-to-void used to silence warnings about an   
   >>      unused expression or unused result.   
   >>   
   >> My question: Why?   
   >   
   > I'll throw a guess on the wall :)   
   >   
   > In C++ you might want to get side effect from some overloaded   
   > operator.  In C the only reason I could think of for for   
   > evaluating *foo and discarding the result would be if *foo   
   > was volatile, and in this way you are poking at some   
   > hardware-mapped address.   
      
   Well, '(void)*foo' effectively says "foo" is not a null pointer   
   (otherwise if would be undefined behaviour).  Good optimizer   
   will _not_ dereference foo, but keep information for further   
   use.   
      
   --   
                                 Waldek Hebisch   
      
   --- 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