Open llvmbot opened 5 years ago
This code is not valid in C++11. The relevant rule is [expr.delete]p1:
The operand shall have a pointer to object type, or a class type having a single non-explicit conversion function ([class.conv.fct]) to a pointer to object type.
This was changed in C++14 to perform a contextual implicit conversion to pointer type; see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf for the change in C++14 that made this code valid. (That was voted into the C++14 working draft at the Portland 2012 meeting of the committee.)
Clang accepts this code in C++14 onwards.
It might be reasonable to accept such code as an extension in earlier language modes, especially since all other compilers appear to have applied it retroactively (accepting it even in their strict/pedantic language modes).
Extended Description
Result of compilation with
-O3 -std=c++11
is below. gcc does not complain on this code.