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

            Bug ID: 50953
           Summary: Missing optimization: if constexpr(false) prevents
                    NRVO
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

Consider the following code:

struct A {
  A() = default;
  A(A&&);
};

template <bool B>
A foo() {
  A a;
  if constexpr (B) {
    return A();
  }
  return a;
}

A test() {
  return foo<false>();
}


In the above example NRVO for `a` is applied by many compilers, but not clang. 

Godbolt playground: https://godbolt.org/z/P8G3zj5GE

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to