Windows assertion failure

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?

- Paul

"Paul J. Lucas" <paul@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

Then there's a bug in the Unix version since the same program on Mac OS X runs without error.

- Paul

Then there's a bug in the Unix version since the same program on Mac OS X runs without error.

Most probably the MacOS version was compiled w/o assertions then.
There is no "Unix version" of LLVM - all platform specifics are
abstracted out in portability layer which does not influence the IR

Not to mention that Mac OS X is a UNIX system.

-- Jean-Daniel