Re: [PATCH] compile: Remove non-const reference parameters

Tom Tromey
2018-09-17T06:32:00Z

>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:

Simon> As mentioned here:
Simon> https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Avoid_non-const_reference_parameters.2C_use_pointers_instead

Simon> we prefer to avoid non-const references. This patch changes the
Simon> non-const references I could find in the compile/ directory, either by
Simon> making them const or changing them to pointers.

Simon> I'd say all the changes are pretty obvious, except the one in
Simon> compile_cplus_instance::enter_scope which might require more attention.

I think this particular change introduced a regression. runtest
gdb.compile/*.exp causes gdb to crash for me several times on x86-64
Fedora 28.

The code does this:

/* Save the new scope. */
m_scopes.push_back (std::move (new_scope));

... but then later code in the function continues to use new_scope,
like:

std::for_each
(new_scope.begin (), new_scope.end () - 1,

Tom