Thread View: comp.std.c++
2 messages
2 total messages
Started by Tom Horsley
Wed, 28 Feb 1996 21:18
Who gets out of memory exception?
Author: Tom Horsley
Date: Wed, 28 Feb 1996 21:18
Date: Wed, 28 Feb 1996 21:18
32 lines
2159 bytes
2159 bytes
Someone showed me the "function try blocks" in the draft standard today, and
I immediately began to wonder what happens if the function in question is
a constructor and one of the exceptions I catch is "out of memory". If I
have something like:
Fred::Fred(...) try : initializers... {
code goes here...
} catch ...
And then I say "new Fred" and run out of memory.
I know some existing C++ implementations call the memory allocation code from
inside the constructor and others call it from the place in the code where
'new' was invoked. So in different implementations today, the exception
might actually occur in the caller or the constructor itself.
Does the standard say who gets the memory exception? Or is running out of
memory even an exception? Or is this simply left undefined?
--
--
Tom.Horsley@mail.hcsc.com
Home: 511 Kingbird Circle Delray Beach FL 33444
Work: Harris Computers, 2101 W. Cypress Creek Rd. Ft. Lauderdale FL 33309
Support Project Vote Smart! They need your support in non-election years too!
(email pvs@neu.edu, 1-800-622-SMART, http://www.vote-smart.org)
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Re: Who gets out of memory exception?
Author: J. Kanze
Date: Thu, 29 Feb 1996 16:00
Date: Thu, 29 Feb 1996 16:00
43 lines
2686 bytes
2686 bytes
In article <TOM.96Feb28161011@amber.ssd.csd.harris.com> tom@ssd.hcsc.com
(Tom Horsley) writes:
|> Someone showed me the "function try blocks" in the draft standard today, and
|> I immediately began to wonder what happens if the function in question is
|> a constructor and one of the exceptions I catch is "out of memory". If I
|> have something like:
|> Fred::Fred(...) try : initializers... {
|> code goes here...
|> } catch ...
|> And then I say "new Fred" and run out of memory.
|> I know some existing C++ implementations call the memory allocation code from
|> inside the constructor and others call it from the place in the code where
|> 'new' was invoked. So in different implementations today, the exception
|> might actually occur in the caller or the constructor itself.
Where the compiler actually generates the call to the memory allocator
is irrelevant. The compiler is required to generate code whose
`observable behavior' is as if the call to the memory allocator preceded
the call to operator new.
|> Does the standard say who gets the memory exception? Or is running out of
|> memory even an exception? Or is this simply left undefined?
The exception (bad_alloc) is thrown by operator new. The first place it
becomes catchable is in the new expression. The constructor is never
called (as far as the observable behavior is concerned).
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils, études et réalisations en logiciel orienté objet --
-- A la recherche d'une activité dans une region francophone
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads