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 33,118 of 33,346    |
|    Chris Uzdavinis to All    |
|    Re: Null pointer from "new" operator.    |
|    02 Jul 13 12:29:09    |
   
   From: cuzdav@googlemail.com   
      
   { Quoted banner and blank lines in quoted section removed -mod }   
      
   On Monday, July 1, 2013 4:47:31 PM UTC-5, alan_mc...@this.is.invalid   
   wrote:   
   > I keep seeing code of the form   
   >   
   > T *t = new T( arg1, ... );   
   > if ( t )   
   > {   
   > // code that uses t   
   > }   
   ...   
   > So can I tell people who write code like this that the "if" is   
   > redundant? Or are there obscure cases where "new" might return a   
   > null pointer?   
      
   Yes, you can tell them that.   
      
   Provided no local overrides of operator new are used, there are no   
   other obscure corner cases where new can return null.   
      
   Note, there is one case where it can return null but I wouldn't call   
   it "obscure" since it explicitly states it throws no exceptions:   
      
    #include
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca