Skip to content

Draft: Avoid reference to temporary

Marco Clemencic requested to merge clemenci-master-patch-33011 into master

this fixes a crash of clang (https://lhcb-nightlies.web.cern.ch/logs/build/nightly/lhcb-gaudi-head/2820/x86_64-centos7-clang10-opt/Analysis/#show_Phys_DecayTreeTupleTracking/Phys_DecayTreeTupleTracking_6):

clang++: /build/gcc/build/contrib/clang-10.0.0/src/clang/10.0.0/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:657: void {anonymous}::CGRecordLowering::insertPadding(): Assertion `Offset >= Size' failed.
...
3.  Phys/DecayTreeTupleTracking/src/TupleToolTrackKink.cpp:127:32: Generating code for declaration 'TupleToolTrackKink::kinkChi2'
...

If my IDE is right, nodes( track ) is actually LHCb::Event::v1::nodes( const LHCb::Event::Track& ) (from TrackFunctors.h#L32-35) which returns a new std::vector<LHCb::FitNode*>. There is no extra cost in getting the new vector by value (thanks to RVO) instead of by reference (which probably works because of the lifetime extension rules), but it prevents the crash in clang.

/cc @sponce

Edited by Marco Clemencic

Merge request reports