[cfe-dev] Differences between linux and macosx

Filipe Cabecinhas filcab at gmail.com
Sun Jun 15 14:50:08 PDT 2008


Hi,

I'm getting a weird error in Linux (gentoo) that doesn't happen in  
MacOS X:

filcab at escher ~ $ cat b.c
#include <alloca.h>
int main ()
{
   char *p = (char *) alloca (2 * sizeof (int));
   if (p) return 0;
   return 0;
}

filcab at escher ~ $ gcc b.c
filcab at escher ~ $ ccc b.c
b.c
clang -emit-llvm-bc -o b.o b.c
clang: Instructions.cpp:713: llvm::Value* getAISize(llvm::Value*):  
Assertion `Amt->getType() == Type::Int32Ty && "Malloc/Allocation array  
size is not a 32-bit integer!"' failed.
clang[0x969ddf]
clang[0x969f00]
/lib/libc.so.6[0x2acbb7d18320]

...

in macosx, clang just happily compiles:
[filcab at farnsworth ~] $ cat b.c
#include <alloca.h>

int main(int argc, char **argv)
{
   char *p = alloca(2 * sizeof(int));
   if (p) return 0;
   return 0;
}

[filcab at farnsworth ~] $ ccc b.c
b.c
clang -emit-llvm-bc -o b.o b.c
llvm-ld -native -disable-internalize -o a.out b.o
[filcab at farnsworth ~] $


They both define alloca(size) to __builtin_alloca(size) after defining  
a prototype for the function and then checking for __GNUC__.


   - Filipe Cabecinhas






More information about the cfe-dev mailing list