===================================================================
@@ -0,0 +1,16 @@
+// PR c++/54165
+
+struct A
+{
+ template<typename T>
+ operator T()
+ {
+ T l[];
+ }
+};
+
+int main()
+{
+ A a;
+ (void)a;
+}
===================================================================
@@ -6053,6 +6053,12 @@ build_static_cast_1 (tree type, tree expr, bool c_
/* [expr.static.cast]
+ Any expression can be explicitly converted to type cv void. */
+ if (TREE_CODE (type) == VOID_TYPE)
+ return convert_to_void (expr, ICV_CAST, complain);
+
+ /* [expr.static.cast]
+
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
@@ -6074,12 +6080,6 @@ build_static_cast_1 (tree type, tree expr, bool c_
/* [expr.static.cast]
- Any expression can be explicitly converted to type cv void. */
- if (TREE_CODE (type) == VOID_TYPE)
- return convert_to_void (expr, ICV_CAST, complain);
-
- /* [expr.static.cast]
-
The inverse of any standard conversion sequence (clause _conv_),
other than the lvalue-to-rvalue (_conv.lval_), array-to-pointer
(_conv.array_), function-to-pointer (_conv.func_), and boolean