aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/Globals.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index 2369d1c8ea..cfecbc91ce 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -76,7 +76,11 @@ GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
const std::string &Name, Module *ParentModule)
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name),
isConstantGlobal(constant) {
- if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
+ if (Initializer) {
+ assert(Initializer->getType() == Ty &&
+ "Initializer should be the same type as the GlobalVariable!");
+ Operands.push_back(Use((Value*)Initializer, this));
+ }
LeakDetector::addGarbageObject(this);