[LLVMbugs] [Bug 341] NEW: Sending a Value* to an ostream should print it's address, not it's contents

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed May 19 10:40:26 PDT 2004


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=341

           Summary: Sending a Value* to an ostream should print it's
                    address, not it's contents
           Product: libraries
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org


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



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list