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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With