home bbs files messages ]

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

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

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

   Message 31,649 of 33,346   
   Ulrich Eckhardt to All   
   Re: Reference to show that if (this == N   
   08 Nov 11 15:50:04   
   
   From: ulrich.eckhardt@dominolaser.com   
      
   Am 07.11.2011 21:02, schrieb Carlos Moreno:   
   > So, the issue: I'm trying to convince a colleague of mine that   
   > using recursion in a tree structure, and allowing it to step outside   
   > the tree by calling the method on the NULL pointers is not legal   
   > (as in, it invokes undefined behaviour).   
   >   
   > The thing is, it's proving to be an "uphill battle", in that the   
   > solution, legal or not, simply happens to work (quite likely works   
   > on every compiler that has ever existed --- at least every "real"   
   > compiler, as opposed to academic/proof-of-concept compilers),   
   > and it simplifies the code a bit.   
      
   Just make the function virtual and watch it break. ;)   
      
   That said, there is at least one compiler out there that (implicitly)   
   guarantees that you can call non-virtual functions on null pointers, and   
   that is MSVC (and probably Intel's in MSVC-compat-mode). MS use this in   
   their MFC class library (e.g. CWnd::GetSafeHWND()).   
      
   Uli   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- 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