Fix deduction of property return values.
Fixes gcc8 compilation error with
prop["foo"]
where prop is a Property<std::map<std::string, std::string> >.
One gets an error like this (trimmed for brevity):
Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx: In constructor 'HelloAlg::HelloAlg(const string&, ISvcLocator*)':
Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx:26:11: error: no match for 'operator[]' (operand types are 'Gaudi::Property<std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >' and 'const char [8]')
m_myDict["Bonjour"] = "Guten Tag";
^
In file included from /home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/GaudiHandle.h:7,
from /home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/ToolHandle.h:5,
from Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.h:10,
from Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx:9:
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h:544:49: note: candidate: 'template<class ARG, class T> decltype (declval<T>()[ARG{}]) Gaudi::Property<TYPE, VERIFIER, HANDLERS>::operator[](const ARG&) [with ARG = ARG; T = T; TYPE = std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >; VERIFIER = Gaudi::Details::Property::NullVerifier; HANDLERS = Gaudi::Details::Property::UpdateHandler]'
inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
^~~~~~~~
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h:544:49: note: template argument deduction/substitution failed:
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h: In substitution of 'template<class ARG, class T> decltype (declval<T>()[ARG{}]) Gaudi::Property<std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >::operator[]<ARG, T>(const ARG&) [with ARG = char [8]; T = std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >]':
Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx:26:21: required from here
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h:544:39: error: taking address of temporary array
inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
~~~~~~~~~~~~~~~~~^
Easiest fix seems to be to use decltype(auto) for the return types.
Edited by Scott Snyder
Merge request reports
Activity
Filter activity
- [2018-03-15 08:04] Validation started with lhcb-gaudi-merge#449
- [2018-03-16 00:05] Validation started with lhcb-gaudi-head-py3#94
- [2018-03-16 00:07] Validation started with lhcb-tdr-test#90
- [2018-03-16 00:08] Validation started with lhcb-gaudi-head#1800
- [2018-03-16 08:02] Validation started with lhcb-gaudi-head#1801
Edited by Software for LHCbassigned to @clemenci
@ssnyder, you should consider fixing the configuration of runners (i.e. allow shared runners) in your fork (https://gitlab.cern.ch/ssnyder/Gaudi/settings/ci_cd)
changed milestone to %v30r2
added bug fix label
mentioned in commit c59ecbba
Please register or sign in to reply