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

            Bug ID: 18731
           Summary: lifetime-extension of conditional temporaries isn't
                    quite right
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

(See core issue 1299 for the full rules.)

Consider:

  bool b;
  struct S { S(int); ~S(); };
  struct T { S s = 0; };
  S &&r = b ? static_cast<S&&>(T().s) : static_cast<S&&>(S(2));

Here, we should lifetime-extend the T object or the S object, depending on
which arm of the conditional is selected. Currently, we lifetime-extend
neither.

While we're here, we fail to lifetime extend in this case:

  using T = int[3];
  //int &&r = T{}[0];
  int &r = T{}[0];

... but we should. (We also reject the commented code because we classify the
array indexing as an lvalue rather than an xvalue; that's a different DR.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to