Skip to content

Current ACTS master does not link with GCC 6.3.1 (was ACTS-289)

Original author Hadrien Benjamin Grasland @hgraslan

As of GCC 6.3.1, the current ACTS master fails to link because the Acts::ParameterSet::NPars symbol is not found. If you'll pardon my French, I get tons of these:

{noformat} CMakeFiles/PropagatorExample.dir/bin/PropagatorExample.cpp.o : Dans la fonction « Acts::ParameterSet<(Acts::ParDef)0, (Acts::ParDef)1, (Acts::ParDef)2, (Acts::ParDef)3, (Acts::ParDef)4>::ParameterSet(std::unique_ptr<Eigen::Matrix<double, 5, 5, 0, 5, 5>, std::default_delete<Eigen::Matrix<double, 5, 5, 0, 5, 5> > >, Eigen::Matrix<double, 5, 1, 0, 5, 1> const&) » : /home/hadrien/Bureau/Programmation/acts/Core/include/ACTS/EventData/ParameterSet.hpp:149 : référence indéfinie vers « Acts::ParameterSet<(Acts::ParDef)0, (Acts::ParDef)1, (Acts::ParDef)2, (Acts::ParDef)3, (Acts::ParDef)4>::NPars » {noformat}

Now, if I look at the declaration of ParameterSet, I do see a declaration of this static member:

{code:c++} template <ParID_t... params> class ParameterSet { private: // local typedefs and constants typedef ParameterSet<params...> ParSet_t; ///< type of this parameter set static constexpr unsigned int NPars = sizeof...(params); ///< number of parameters stored in this class // ... {code}

But according to http://en.cppreference.com/w/cpp/language/static, declaring this constexpr is not enough. To summarize the convoluted rules of static constexprs:

  • Static constexprs must be initialized at the point where they are declared
  • But until C++17, a separate definition is also needed if a reference to the constexpr is ever taken. Which apparently happens, for reasons I could not determine.

Correct compilation can be restored, for now, by adding a separate definition of ParameterSet::NPars to the header file. Once we switch to std=c++17, we'll hopefully be able to get rid of that.

Edited by Moritz Kiehn
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information