[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: c++/3827: new int problem.



fasbjx@libertysurf.fr, Branjonneau@free.fr writes:

|   template< typename T, int role, bool ndebug >
|   struct init {
|     static T * do_it() { 
|       T* tmp(new T);
|       std::cout << "/tmp/ point to: " << *tmp << "\n";
|       return tmp;
|     }
|   };

| /tmp/ point to: 0
| /tmp/ point to: 1075812784

Hi,

This is not a bug in the compiler.

For fundamental types, a direct-new-expression of the form 'new T'
does -not- do default initialization.  If you hve to say

	new T()

to get default initialization.  Please note the parens.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com



Reply to: