Value* from ValueAsMetadata::getValue() gone

So this is the two lines of code:

ValueAsMetadata v = static_cast<ValueAsMetadata>(metadata->getOperand(i)->getOperand(0).get());
Value *val = v->getValue();

After executing these two lines, in gdb:

(gdb) print val
$1 = (llvm::Value *) 0x0
(gdb) print v->getValue()
$2 = (llvm::Value *) 0x4346d68

How could this happen?

Could you provide full reproduction steps, if possible? (ie: reproducible with existing LLVM source, or if necessary, a small patch - then exactly what command line to run under GDB, where to break, step, print, etc)