www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Using alloca?

reply "Maxime Chevalier-Boisvert" <maximechevalierb gmail.com> writes:
I'd like to stack-allocate an array that will be dynamically 
sized. Is alloca somewhere in the standard D library? If so, what 
should I import to have access to it?
Jun 27 2013
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/27/13 9:42 PM, Maxime Chevalier-Boisvert wrote:
 I'd like to stack-allocate an array that will be dynamically sized. Is
 alloca somewhere in the standard D library? If so, what should I import
 to have access to it?

Yah, import core.stdc.stdlib. Andrei
Jun 27 2013
prev sibling next sibling parent Marco Leise <Marco.Leise gmx.de> writes:
Am Fri, 28 Jun 2013 06:42:31 +0200
schrieb "Maxime Chevalier-Boisvert"
<maximechevalierb gmail.com>:

 I'd like to stack-allocate an array that will be dynamically 
 sized. Is alloca somewhere in the standard D library? If so, what 
 should I import to have access to it?

As a side note, in Mono-D you can just type alloca, then press Ctrl+Alt+Space and the correct import magically appears at the top of the source file. -- Marco
Jun 28 2013
prev sibling next sibling parent "Maxime Chevalier-Boisvert" <maximechevalierb gmail.com> writes:
On Friday, 28 June 2013 at 05:27:54 UTC, Andrei Alexandrescu 
wrote:
 On 6/27/13 9:42 PM, Maxime Chevalier-Boisvert wrote:
 I'd like to stack-allocate an array that will be dynamically 
 sized. Is
 alloca somewhere in the standard D library? If so, what should 
 I import
 to have access to it?

Yah, import core.stdc.stdlib. Andrei

Thank you good sir :)
Jun 28 2013
prev sibling next sibling parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 28.06.2013 06:42, schrieb Maxime Chevalier-Boisvert:
 I'd like to stack-allocate an array that will be dynamically sized. Is
 alloca somewhere in the standard D library? If so, what should I import
 to have access to it?

The last time I checked alloca did not work well together with execptions. Whenever a exception whas thrown thourgh a stack frame which used alloca the app would crash. (on dmd Windows 64 bit, which uses the same exception mechanism as the linux versions of dmd) -- Kind Regards Benjamin Thaut
Jun 28 2013
parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 28.06.2013 20:01, schrieb bearophile:
 Benjamin Thaut:

 The last time I checked alloca did not work well together with
 execptions. Whenever a exception whas thrown thourgh a stack frame
 which used alloca the app would crash. (on dmd Windows 64 bit, which
 uses the same exception mechanism as the linux versions of dmd)

Is this in Bugzilla? Bye, bearophile

Yes, its a pretty old bug too: http://d.puremagic.com/issues/show_bug.cgi?id=3753 -- Kind Regards Benjamin Thaut
Jun 28 2013
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Benjamin Thaut:

 The last time I checked alloca did not work well together with 
 execptions. Whenever a exception whas thrown thourgh a stack 
 frame which used alloca the app would crash. (on dmd Windows 64 
 bit, which uses the same exception mechanism as the linux 
 versions of dmd)

Is this in Bugzilla? Bye, bearophile
Jun 28 2013