I have a class with following template member function:
template<typename T, typename Loc = std::initializer_list<size_t>>
auto get_slot(Loc loc) -> T*&
requires types::LocatorContainer<Loc>
{
const auto pos = header.loc2pos(loc);
if (!header.set_map_index(pos, pos)) {
spdlog::warn("Category {} was already compressed, can't add new slots.", header.name);
throw std::runtime_error("Cannot access compressed category");
}
return reinterpret_cast<T*&>(data->operator[](types::size_t2int(pos)));
}
The class has generated dictionary with
// the header
ClassDefOverride(the_class, 1)
// Linkdef
#pragma link C++ class the_class+;
While opening up a ROOT file with stored object of this class in the TBrowser
(I can do root file.root
but the error shwos up when I clink on the file in the browser), I end up with following error:
path/to/header/file.hpp:204:26: error: call to consteval function 'fmt::fstring<std::basic_string<char, std::char_traits<char>, std::allocator<char> > &>::fstring<57UL>' is not a constant expression
spdlog::warn("Category {} was already compressed, can't add new slots.", header.name);
^
note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
The full crash stack is:
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007fe19b916417 in ?? () from /usr/lib64/libc.so.6
#1 0x00007fe19b916441 in ?? () from /usr/lib64/libc.so.6
#2 0x00007fe19b98552b in wait4 () from /usr/lib64/libc.so.6
#3 0x00007fe19b8d6dfb in ?? () from /usr/lib64/libc.so.6
#4 0x00007fe19c0942c0 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.34
#5 0x00007fe19c093b84 in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.34
#6 <signal handler called>
#7 0x00007fe198718173 in ?? () from /usr/lib64/root/libCling.so
#8 0x00007fe195956800 in ?? () from /usr/lib64/root/libCling.so
#9 0x00007fe1959577ac in ?? () from /usr/lib64/root/libCling.so
#10 0x00007fe19595791b in ?? () from /usr/lib64/root/libCling.so
#11 0x00007fe195923c31 in ?? () from /usr/lib64/root/libCling.so
#12 0x00007fe1959240b6 in ?? () from /usr/lib64/root/libCling.so
#13 0x00007fe195906f96 in ?? () from /usr/lib64/root/libCling.so
#14 0x00007fe19598dc38 in ?? () from /usr/lib64/root/libCling.so
#15 0x00007fe195991007 in ?? () from /usr/lib64/root/libCling.so
#16 0x00007fe195907abe in ?? () from /usr/lib64/root/libCling.so
#17 0x00007fe195907c37 in ?? () from /usr/lib64/root/libCling.so
#18 0x00007fe19582b4f5 in ?? () from /usr/lib64/root/libCling.so
#19 0x00007fe19582d619 in TCling::AutoParseImplRecurse(char const*, bool) () from /usr/lib64/root/libCling.so
#20 0x00007fe1958343f0 in TCling::AutoParse(char const*) () from /usr/lib64/root/libCling.so
#21 0x00007fe19c022229 in TClass::LoadClassInfo() const () from /usr/lib64/root/libCore.so.6.34
#22 0x00007fe19c024968 in TClass::NewObject(TClass::ENewType, bool) const () from /usr/lib64/root/libCore.so.6.34
#23 0x00007fe19c028125 in TClass::New(TClass::ENewType, bool) const () from /usr/lib64/root/libCore.so.6.34
#24 0x00007fe19b2ed8db in TKey::IsFolder() const () from /usr/lib64/root/libRIO.so
#25 0x00007fe181353afc in TGFileBrowser::GetObjPicture(TGPicture const**, TObject*) () from /usr/lib64/root/libGui.so.6.34.08
#26 0x00007fe181353e30 in TGFileBrowser::AddKey(TGListTreeItem*, TObject*, char const*) () from /usr/lib64/root/libGui.so.6.34.08
#27 0x00007fe181354615 in TGFileBrowser::Add(TObject*, char const*, int) () from /usr/lib64/root/libGui.so.6.34.08
#28 0x00007fe19c013e0b in TBrowser::Add(TObject*, char const*, int) () from /usr/lib64/root/libCore.so.6.34
#29 0x00007fe19b2aea41 in TDirectoryFile::Browse(TBrowser*) () from /usr/lib64/root/libRIO.so
#30 0x00007fe1813552b3 in TGFileBrowser::DoubleClicked(TGListTreeItem*, int) () from /usr/lib64/root/libGui.so.6.34.08
#31 0x00007fe19588b226 in TClingCallFunc::exec(void*, void*) () from /usr/lib64/root/libCling.so
#32 0x00007fe19bf66698 in TQConnection::SendSignal() () from /usr/lib64/root/libCore.so.6.34
#33 0x00007fe18139fb2b in ?? () from /usr/lib64/root/libGui.so.6.34.08
#34 0x00007fe1813a3455 in TGListTree::HandleDoubleClick(Event_t*) () from /usr/lib64/root/libGui.so.6.34.08
#35 0x00007fe18137e0bd in TGFrame::HandleEvent(Event_t*) () from /usr/lib64/root/libGui.so.6.34.08
#36 0x00007fe18131db1d in TGClient::HandleEvent(Event_t*) () from /usr/lib64/root/libGui.so.6.34.08
#37 0x00007fe18131e005 in TGClient::ProcessOneEvent() () from /usr/lib64/root/libGui.so.6.34.08
#38 0x00007fe18131e05a in TGClient::HandleInput() () from /usr/lib64/root/libGui.so.6.34.08
#39 0x00007fe19c0933eb in TUnixSystem::DispatchOneEvent(bool) () from /usr/lib64/root/libCore.so.6.34
#40 0x00007fe19bf97259 in TSystem::Run() () from /usr/lib64/root/libCore.so.6.34
#41 0x00007fe19bf17927 in TApplication::Run(bool) () from /usr/lib64/root/libCore.so.6.34
#42 0x00007fe19c25142d in TRint::Run(bool) () from /usr/lib64/root/libRint.so.6.34
#43 0x0000562e4486f303 in main ()
Any idea how to deal with it?
Setup
ROOT v6.34.08
Built for linuxx8664gcc on Apr 22 2025, 15:05:04
From tags/6-34-08@6-34-08
With
Binary directory: /usr/bin
Additional context
ROOT compiled with C++20 and my code with C++23.