[LLVMbugs] [Bug 16205] New: incorrect ordering of scalar initialization and destruction of temporaries

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 3 00:04:21 PDT 2013


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

            Bug ID: 16205
           Summary: incorrect ordering of scalar initialization and
                    destruction of temporaries
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider:

struct S { S(int&); ~S(); };
void f() { int n = (S(n), 0); }

G++ and EDG initialize n before the S temporary is destroyed. Clang initializes
n afterwards (thus n is uninitialized if S's destructor looks at it).

This hinges on whether the initialization of the scalar is part of the
full-expression or not. The standard doesn't appear to mention this, but if
such initialization is not part of the full-expression then nothing sequences
it with the rest of the evaluation of the program. Presumably the intent is
that scalar initialization *is* part of the full-expression, and so must be
performed before the destructor runs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130603/c14775db/attachment.html>


More information about the llvm-bugs mailing list