signal 11 generating problem, was: Further observations regarding alloca on i586-pc-linux-gnu
Alexandre Oliva
oliva@dcc.unicamp.br
Tue Aug 25 19:31:00 GMT 1998
Joerg Pommnitz <pommnitz@darmstadt.gmd.de> writes:
> Martin von Loewis wrote:
>> I'd say auto_ptrs are there for you, no? Somebody correct me, but it
>> seems that
>>
>> void f(char * = std::auto_ptr<char*>(new char[20]));
>> is valid C++, and gives you memory that will live slightly longer than
>> the call to f, and will then be automatically deallocated.
Yup, it's syntactically valid C++, but it is wrong because auto_ptr
will delete the pointer to the array as if it were a pointer to a
single object. You should write auto_ptr_array instead.
> Returning an auto_ptr is not really an option. According to Stroustrup,
> "The C++ Programming Language" 3rd Edition page 368, auto_ptr does not
> contain a cast operator to its element type.
But it provides a get() method, that you could use to obtain the
pointer to the contained object.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc
mailing list