[LLVMbugs] [Bug 5539] New: lifetime of conditional temporaries is incorrect

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Nov 17 09:52:01 PST 2009


http://llvm.org/bugs/show_bug.cgi?id=5539

           Summary: lifetime of conditional temporaries is incorrect
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: victor.zverovich at googlemail.com
                CC: llvmbugs at cs.uiuc.edu


Conditional temporaries are destroyed not at the end of the full expression as
in gcc but apparently at the end of the conditional branch.

For example, consider the program below:

#include <stdio.h>

struct S
{
    int i;
    S() { puts("S"); }
    ~S() { puts("~S"); }
};

void f(int) { puts("f"); }

volatile bool b = true;

int main()
{
    f(b ? S().i : 0);
}

If it is compiled with gcc and run the output is: 
S
f
~S

With clang the output is:
S
~S
f

The same applies to && and || operators.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list