3 ms·
Well, alloca is not specified in any formal standard, so you won't find an official ruling on whether it's undefined, unspecified or well-defined. By itself, th
by psykotic 15y ago
Well, alloca is not specified in any formal standard, so you won't find an official ruling on whether it's undefined, unspecified or well-defined. By itself, that state of affairs should strongly discourage its use in portable code.
- ams6110 15y agoAt the bottom of my man page: BUGS The alloca() function is machine and compiler dependent; its use is dis- couraged.
- FooBarWidget 15y agoI interpret that statement as it being similar to __asm__(), which is also machine and compiler dependent and discouraged in portable code. Still, sometimes you need it when writing low-level code. __asm__ doesn't blow up the way alloca in the given example does.
- psykotic 15y agoIncidentally, I ran into a nasty x64 __asm__ codegen bug with exactly the same compiler version that this blog post covers. It was in lockless multithreaded code, so you can imagine how much fun that was to debug. Rather than work around it, I ended up replacing all our GCC inline assembly with modern intrinsics like __sync_fetch_and_add.
- mikeash 15y agoThe example doesn't blow up at all, it just doesn't happen to behave in exactly the same way as a different compiler.