A beginner question

I feel a bit bad for always asking beginner questions here but I am having some difficulties with a runtime error with which I could use some help diagnosing.

1) I am getting the assertion failure

main: Type.cpp:1309: static llvm::PointerType* llvm::PointerType::get(const llvm::Type*, unsigned int): Assertion `ValueType && "Can't get a pointer to <null> type!"' failed.

from this line-

fields.push_back( llvm::PointerType::getUnqual(llvm::Type::Int32Ty) );

Is something needed to initialize the llvm::Type::Int32Ty?

Thanks in advance,

Carter

Carter Cheng wrote:

I feel a bit bad for always asking beginner questions here but I am having some difficulties with a runtime error with which I could use some help diagnosing.

1) I am getting the assertion failure

main: Type.cpp:1309: static llvm::PointerType* llvm::PointerType::get(const llvm::Type*, unsigned int): Assertion `ValueType && "Can't get a pointer to <null> type!"' failed.

from this line-

fields.push_back( llvm::PointerType::getUnqual(llvm::Type::Int32Ty) );

Is something needed to initialize the llvm::Type::Int32Ty?

Type::Int32Ty is a static const Type* with an initializer. You might need static constructors to run in order to initialize it, but in C++ that should require no action on your part.

It should be impossible for that line of code to cause that assertion. Are you sure you're blaming the right line? If so then you probably have a larger problem with your C++ environment, such as LLVM being miscompiled by your system compiler. (It's not one of the ones listed on llvm.org/docs/GettingStarted.html#brokengcc is it?)

Nick

The line comes up on a back trace using gdb. I think it's the right line (I have tried it on two separate machines one using Fedora 11 and g++ 4.4.x and the other Ubunto and g++ 4.3.3) and the situation is exceptionally odd since it only occurs when compiling my Runtime.cpp and doesnt happen when compiling other files. This is with LLVM 2.5.

I did look at the Type.cpp code and it should be impossible but it's the error I am getting.

Carter Cheng wrote:

The line comes up on a back trace using gdb. I think it's the right line (I have tried it on two separate machines one using Fedora 11 and g++ 4.4.x and the other Ubunto and g++ 4.3.3) and the situation is exceptionally odd since it only occurs when compiling my Runtime.cpp and doesnt happen when compiling other files. This is with LLVM 2.5.

Just a thought, but this can happen due to undefined static initialization ordering. If the code is getting called based on some static initialization that is happening before main() then that could be your problem. This happened to me once through a convoluted chain of initialization.

Luke