https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63999
Bug ID: 63999 Summary: Explcit conversion operators are not considered for explicit cast using brace Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tomaszkam at gmail dot com For the following code: struct bool_convert { explicit operator bool() { return true; } }; bool x(bool_convert()); //1 bool x1{bool_convert{}}; //2 bool x2 = bool{bool_convert{}}; //3 Both line 1 and 2 compiles correcty, while the line 3 produces following error: error: cannot convert 'bool_convert' to 'bool' in initialization. According to the standard section $5.2.3 [expr.type.conv]/3: Similarly, a simple-type-specifier or typename-specifier followed by a braced-init-list creates a temporary object of the specified type direct-list-initialized (8.5.4) with the specified braced-init-list, and its value is that temporary object as a prvalue. That means that cast notation from the line 3 should have equivalent semantics to the one from line 2. Section $12.3.2 [class.conv.fct]/2: A conversion function may be explicit (7.1.2), in which case it is only considered as a user-defined conversion for direct-initialization (8.5). Otherwise, user-defined conversions are not restricted to use in assignments and initializations. Explicit conversion operator should be invoked for direct initialization so behaviour for line 3 is incoorect and conversion operator should be used.