[llvm-bugs] [Bug 40245] New: Missed guaranteed copy elision in delegating constructor with ?: operator

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 7 08:01:13 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40245

            Bug ID: 40245
           Summary: Missed guaranteed copy elision in delegating
                    constructor with ?: operator
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++'17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: john at jmdtech.org
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 21300
  --> https://bugs.llvm.org/attachment.cgi?id=21300&action=edit
reproducible source code

This particular case of a missed guaranteed copy elision prevents clang from
compiling libstdc++ std::optionals with types that are not trivially copyable.
The example reproducible source is a minimization of the implementation of
std::optional in libstdc++.

https://gcc.godbolt.org/z/5gK3So

The problem appears to be that clang is missing its obligation to elide the
copy in the delegating constructor that uses the ternary operator to choose
between two constructors to delegate to. The ternary (?:) operator is defined
as a prvalue, so I believe this should qualify for the guaranteed copy elision
in c++17.

-- 
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/20190107/237b9e64/attachment.html>


More information about the llvm-bugs mailing list