user3165937
user3165937

Reputation: 61

GCC template deduction removes const bug?

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

Answers (1)

hlt
hlt

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

Related Questions