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

Richard Smith <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |INVALID

--- Comment #2 from Richard Smith <[email protected]> ---
[expr.static.cast]p4: "An expression e can be explicitly converted to a type T
using a static_cast of the form static_cast<T>(e) if the declaration T t(e); is
well-formed, for some invented temporary variable t (8.5)."

Thus we can reduce to a testcase not involving static_cast:

  struct B {};
  struct S { explicit operator B(); };
  B const &t(S{});

... which GCC and EDG reject, and Clang still accepts. And the above testcase
is valid:

Per 8.5.3/5.2.1.2, the relevant rules for selecting conversion functions are
those in 13.3.1.6, not those in 13.3.1.5.

Per 13.3.1.6, "For direct-initialization, those explicit conversion functions
that are not hidden within S and yield type “lvalue reference to cv2 T2” or
“cv2 T2” or “rvalue reference to cv2 T2”, respectively, where T2 is the same
type as T or can be converted to type T with a qualification conversion (4.4),
are also candidate functions."

So the explicit conversion operator is considered here, and both the
initialization and the static_cast are permitted.

-- 
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