Making alloca more safe

Denis Koroskin 2korden at gmail.com
Mon Nov 16 01:34:15 PST 2009


C standard library alloca function has an undefined behavior when  
requested size is large enough to cause a stack overflow, but many (good)  
implementations return null instead. So does DMD, for example. I believe  
it would be even better to go ahead and enforce D implementation to return  
a GC allocated chunk of memory instead of null in that case. It will not  
incur any performance hit in 99.9% of the cases and prevent a bug from  
being happen in the rest. It will also make writing code using it easier  
(and more safe), since you don't have to worry about possible stack  
overflow/null-dereference.



More information about the Digitalmars-d mailing list