Given this small program:> #include <llvm/DerivedTypes.h> > #include <llvm/LLVMContext.h> > > using namespace llvm; > > int main( int argc, char const *argv[] ) { > LLVMContext &ctx = getGlobalContext(); > > Type *void_type( Type::getVoidTy( ctx ) ); > PointerType *void_ptr_type( void_type->getPointerTo() ); > > return 0; > }When compiled using the clang binaries with MinGW32 and run, I get:> Assertion failed: isValidElementType(EltTy) && "Invalid type for pointer element!", file /Users/asl/Projects/llvm/release/3.1/src/lib/VMCore/Type.cpp, line 748Why? - Paul
"Paul J. Lucas" <paul at lucasmail.org> writes:> Given this small program: > >> #include <llvm/DerivedTypes.h> >> #include <llvm/LLVMContext.h> >> >> using namespace llvm; >> >> int main( int argc, char const *argv[] ) { >> LLVMContext &ctx = getGlobalContext(); >> >> Type *void_type( Type::getVoidTy( ctx ) ); >> PointerType *void_ptr_type( void_type->getPointerTo() ); >> >> return 0; >> } > > When compiled using the clang binaries with MinGW32 and run, I get: > >> Assertion failed: isValidElementType(EltTy) && "Invalid type for >> pointer element!", file >> /Users/asl/Projects/llvm/release/3.1/src/lib/VMCore/Type.cpp, line >> 748 > > Why?In LLVM there are no pointers to void. Try a pointer to i8 (a.k.a. char for most C/C++ programmers).
> When compiled using the clang binaries with MinGW32 and run, I get: >> Assertion failed: isValidElementType(EltTy) && "Invalid type for pointer element!", file /Users/asl/Projects/llvm/release/3.1/src/lib/VMCore/Type.cpp, line 748 > Why?Because there is no void* in LLVM IR world -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Then there's a bug in the Unix version since the same program on Mac OS X runs without error. - Paul On May 28, 2012, at 10:15 AM, Anton Korobeynikov <anton at korobeynikov.info> wrote:>> When compiled using the clang binaries with MinGW32 and run, I get: >>> Assertion failed: isValidElementType(EltTy) && "Invalid type for pointer element!", file /Users/asl/Projects/llvm/release/3.1/src/lib/VMCore/Type.cpp, line 748 >> Why? > Because there is no void* in LLVM IR world