Reputation: 61
I found this snippet compiles and runs with GCC7.3 but not with clang7:
const std::vector foo({1, 2, 3, 4}); foo.clear();
I expect a compiler error but GCC happily clears the vector.
Upvotes: 6
Views: 127
Reputation: 6317
This is GCC bug 83818; it is fixed with GCC 8.
There is unfortunately not much more information there – the only "fix" appears to be not using class template argument deduction or upgrading the compiler.
Upvotes: 4