https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85958

--- Comment #12 from Jonny Grant <jg at jguk dot org> ---
Another example const.cpp attached.

The message doesn't mention it's the const qualifier.

Expected:
<source>:6:21: error: passing 'const
std::vector<std::__cxx11::basic_string<char> >' as 'this' argument discards
const qualifier [-fpermissive]

    6 |     vec.push_back("");

      |                     ^



Output:


#1 with x86-64 gcc (trunk)
<source>: In function 'void f(const
std::vector<std::__cxx11::basic_string<char> >&)':

<source>:6:21: error: passing 'const
std::vector<std::__cxx11::basic_string<char> >' as 'this' argument discards
qualifiers [-fpermissive]

    6 |     vec.push_back("");

      |                     ^

In file included from
/opt/compiler-explorer/gcc-trunk-20200506/include/c++/11.0.0/vector:67,

                 from <source>:2:

/opt/compiler-explorer/gcc-trunk-20200506/include/c++/11.0.0/bits/stl_vector.h:1203:7:
note:   in call to 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp,
_Alloc>::value_type&&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc =
std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp,
_Alloc>::value_type = std::__cxx11::basic_string<char>]'

 1203 |       push_back(value_type&& __x)

      |       ^~~~~~~~~

Compiler returned: 1

Reply via email to