public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@dcc.unicamp.br>
To: Joerg Pommnitz <pommnitz@darmstadt.gmd.de>
Cc: Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>,
	egcs@cygnus.com, egcs-bugs@cygnus.com
Subject: Re: signal 11 generating problem,  was: Further observations regarding alloca on i586-pc-linux-gnu
Date: Tue, 25 Aug 1998 19:31:00 -0000	[thread overview]
Message-ID: <oraf4sq5yo.fsf@iguacu.dcc.unicamp.br> (raw)
In-Reply-To: <35E29107.72AB8560@darmstadt.gmd.de>

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


  reply	other threads:[~1998-08-25 19:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-20  9:09 Joerg Pommnitz
1998-08-21  8:17 ` Noel Yap
1998-08-21 16:30 ` Alexandre Oliva
1998-08-22 11:00   ` Carlo Wood
1998-08-23  4:36     ` Richard Henderson
1998-08-23 12:13       ` Martin von Loewis
1998-08-23 18:49         ` Richard Henderson
1998-08-25 19:31           ` Martin von Loewis
1998-08-24  4:37         ` Jeffrey A Law
1998-08-25  7:28           ` Martin von Loewis
1998-08-24 10:48       ` Joerg Pommnitz
1998-08-25 12:45         ` Martin von Loewis
1998-08-25 19:31           ` Joerg Pommnitz
1998-08-25 19:31             ` Martin von Loewis
1998-08-25 23:05               ` signal 11 generating problem, was: " Joerg Pommnitz
1998-08-25 19:31                 ` Alexandre Oliva [this message]
1998-08-25 19:31                   ` Joerg Pommnitz
1998-08-25 23:05                   ` Martin von Loewis
1998-08-26  8:25                     ` Joe Buck
1998-08-26  5:20               ` Noel Yap
1998-08-26 11:57                 ` Joe Buck
1998-08-26  3:53             ` Andreas Schwab
1998-08-26 12:26             ` Oleg Zabluda
1998-08-27 13:38               ` Alexandre Oliva
1998-08-25 19:31         ` Richard Henderson
1998-08-26  5:20 signal 11 generating problem, was: " Sol Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=oraf4sq5yo.fsf@iguacu.dcc.unicamp.br \
    --to=oliva@dcc.unicamp.br \
    --cc=egcs-bugs@cygnus.com \
    --cc=egcs@cygnus.com \
    --cc=martin@mira.isdn.cs.tu-berlin.de \
    --cc=pommnitz@darmstadt.gmd.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).