[LLVMbugs] [Bug 513] NEW: [llvm-g++] Temporary lifetimes incorrect for short circuit logical operations

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Feb 14 22:33:28 PST 2005


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

           Summary: [llvm-g++] Temporary lifetimes incorrect for short
                    circuit logical operations
           Product: tools
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-g++
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org


Testcase:

----
#include <stdio.h>

struct X {
  int Val;
  X(int i) : Val(i) { printf("X::X(%d)\n", Val); }
  ~X() { printf("X::~X(%d)\n", Val); }
};

bool foo(const X &) { return true; }
void bar() {}
int main() {
  if ((foo(1) || foo(2)))
    bar();
}
---

Output:

X::X(1)
X::~X(164531856)
X::~X(1)

The problem is that the temporary for "foo(2)" is destroyed even if the second
part of the || is not executed (which would create the temporary).

This problem is distilled from QDirPrivate::setPath in QT4.0.

-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