Bugzilla – Bug 341
Sending a Value* to an ostream should print its address, not its contents
Last modified: 2004-07-15 10:09:02
You need to log in before you can comment on or make changes to this bug.
Vikram pointed out this inconsistency long ago, but it still remains: Value *X = ... std::cout << "Addr: " << X << " Contents: " << *X; Both of these print out the *contents* of X. The only way to print the address of a Value* is currently to cast it to a void* like this: std::cout << "Addr: " << (void*)X << " Contents: " << *X; Ick. Changing this should be quite simple, but the problem is that it will probably break a lot of code that is still relying on printing of addresses to print the contents of the value. The best way to fix this is probably to change operator<< for Value*'s to be a template that causes a compile time problem when used. Once this happens, the compiler will identify where it's being used, and all uses can be switched over to using the reference printing version. Once the sourcebase is checked, the template can be removed. -Chris
mine
This bug is now fixed. There were many patches, but this is the one that matters: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040712/016026.html std::cerr << Value* will now print he address of the object, not its contents. -Chris