That's why I use it. It seems to work fine if you use it wisely. As for it being portable, heck if I know. I don't care if Windows can't do something Linux can because I hate Windows.
O_o
The things you hear when you don't have an elephant gun, a sack of lime, and deep hole.
*shrug*
Anyway, `alloca' support has nothing to do with the operating system; the function is or is not a feature of a compiler.
Look at the example from Hodor:
Code:
char *mem = alloca(909204922490);
With many implementations of `alloca', you have no way of knowing if the allocation was successful, and without that information "use it wisely" is off the table. Unlike simple over-allocation or "VLA", the problem here isn't born simply of overflowing the stack; the unreliability of the implementations (The return value being undefined with problematic allocation is only one problem area.) is unsuitable for stable code even when overflow doesn't occur.
[Edit]
By the by Hodor, this is where you went in the wrong direction. The over-allocation as with "VLA" or other automatic variable has nothing to do with my comments. The poorly defined and respected semantics make `alloca' a big potential for crash and burn whether the stack overflows or not.
[/Edit]
Code:
DoSomething(alloca(1), alloca(1));
Even though this sample code is extremely unlikely to overflow the stack under normal circumstances, this sample has an extreme potential for incredibly difficult to debug problems.
Code:
void * s = alloca(1);
DoSomething(s, alloca(1));
This simple code has the same problem.
Code:
void * s1 = alloca(1);
DoSomething(s, 0);
void * s2 = alloca(1);
This simple example may also fail for similar reasons.
Of course, just because reality can be a pain, these simple examples all work differently with different implementations though when faulty they all crash and burn. With some compilers, the second and third may work fine, but with other compilers only the first and second work, and in all of those cases, the client code has no way of inspecting for such faults.
[Edit]
Naturally, anyone may use whatever they wish; Yog Sothoth knows I use an awful, filthy sort of hack in my libraries, but MutantJohn, you shouldn't use it without considerable effort in understanding exactly where and how support for `alloca' works.
That last bit was unnecessarily condescending, and though I in no way intended that I still do apologize. I'm sorry for that.
Let me instead put it this way: `alloca' is more difficult to implement correctly than one might think and even that is before the optimizer gets involved, so before you continue to use it, spend some time familiarizing yourself with the sins of the particular implementation you use.
[/Edit]
Soma