Skip to content
Commit 484d37cf authored by Roger Ferrer's avatar Roger Ferrer Committed by Ferran Pallares
Browse files

Fix initialization of const references

Reference lifetime extension only applies in this case

  const T& R = T(...);

or

  const T& R = f(...);  // where f returns T

This means the temporary bound to R will be destroyed at the end of the
block so R can be safely used until then.

However it does not apply in this case

  const T& R = T(...).modifier(...);

not even if T::modifier returns 'const T&'. It doesn't matter: the
temporary T() will be destroyed at the ';"

MachineInstrBuilder has a particularly annoying error-prone API that
leads to these kind of errors.

Let's not use 'const MachineInstrBuilder &' ever. Not even when it could
work: just in case later we decide to extend the instruction being built
calling a 'modifier'.
parent 0389e058
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment