This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Marking C++ new operator as malloc?


Richard Guenther wrote:

> I don't know of any place we would use such information.  At least
> 
>   int *p = new int;
>   int *q = new int;
>   if (p == q)
> 
> cannot be simplified as both pointers may be NULL?

They cannot be NULL; new-expressions throw an exception if the
allocation fails.  (Of course, they could be NULL if you called the
"nothrow" variant, or another "operator new" declared "throw()".)

We should optimize away things like:

  int *p = new int;
  if (!p)
    cerr << "Could not allocate memory\n";

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]