Dictionary issue with consteval and spdlog/fmt

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.

Hi @rlalik ,

May be @pcanal can help with your problem.

This seems to be an issue with the interpretation of your header files. You may need to provide us with a complete reproducer to make progress on this issue.

@devajithvs any ideas?

Hi, I will ping this topic to avoid closing after 14 days, but my bad/good news is that while I was preparing the code to be committed to the repo for providing WE, I had to do something that this error was gone. I tried to bring it back but wasn’t succesful.
But now I have similar but different errors, let me try to demonstrate them soon.

Ok, this time I have following issue:

When opening the root file with tree T in the browser, when expanding the data member (which is of TClonesArray) inside the leaf (custom class derived from TObject with auto IsFolder() const -> Bool_t override { return kTRUE; }), as shown in the image:

the following error pop-ups (but only when double clicking on data member, not earlier):

root [2] libsabat dictionary payload:17:10: remark: could not acquire lock file for module 'sabat': failed to create unique file /usr/lib64/root/sabat.pcm.lock-cfd0d3ec: Permission denied [-Rmodule-build]
#include "/home/rafal/sabat/src/sabat-framework/include/sabat/sabat_categories.hpp"
         ^
libsabat dictionary payload:17:10: remark: building module 'sabat' as '/usr/lib64/root/sabat.pcm' [-Rmodule-build]
error: unable to open output file '/usr/lib64/root/sabat.pcm': 'Permission denied'
libsabat dictionary payload:17:10: remark: finished building module 'sabat' [-Rmodule-build]
libsabat dictionary payload:17:10: fatal error: could not build module 'sabat'
#include "/home/rafal/sabat/src/sabat-framework/include/sabat/sabat_categories.hpp"
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error in <TInterpreter::AutoParse>: Error parsing payload code for class SabatRaw with content:

#line 1 "libsabat dictionary payload"

#ifndef FMT_SHARED
  #define FMT_SHARED 1
#endif
#ifndef SPDLOG_SHARED_LIB
  #define SPDLOG_SHARED_LIB 1
#endif
#ifndef SPDLOG_COMPILED_LIB
  #define SPDLOG_COMPILED_LIB 1
#endif
#ifndef SPDLOG_FMT_EXTERNAL
  #define SPDLOG_FMT_EXTERNAL 1
#endif

#define _BACKWARD_BACKWARD_WARNING_H
// Inline headers
#include "/home/rafal/sabat/src/sabat-framework/include/sabat/sabat_categories.hpp"
#include "/home/rafal/sabat/src/sabat-framework/include/sabat/sabat_definitions.hpp"

#undef  _BACKWARD_BACKWARD_WARNING_H

Error in <TClass::LoadClassInfo>: no interpreter information for class SabatRaw is available even though it has a TClass initialization routine.

It tries t make pcm file inside /usr/lib64/root/ which is my ROOT lib’s installation path.
However I have in my current directory:

-rw-r--r-- 1 rafal rafal    2887 06-05 20:32 libsabat_rdict.pcm
-rw-r--r-- 1 rafal rafal     567 06-05 20:32 libsabat.rootmap
lrwxrwxrwx 1 rafal rafal      13 06-06 12:23 libsabat.so -> libsabat.so.0
lrwxrwxrwx 1 rafal rafal      17 06-06 12:23 libsabat.so.0 -> libsabat.so.0.1.0
-rwxr-xr-x 1 rafal rafal 2245280 06-06 12:23 libsabat.so.0.1.0

and

$ echo $LD_LIBRARY_PATH
/home/rafal/sabat/src/sabat-framework/build/default:/tmp/spark/lib64/:/home/rafal/usr/lib64:/home/rafal/.local/lib64
$ pwd
/home/rafal/sabat/src/sabat-framework/build/default

which makes rootlogon script loading the proper dictionaries. This is the error I met for the second time, and have no idea how to handle it.

Is it connected with the features the root is compiled:

$ root-config --features
cxx23 asimage asimage_tiff builtin_clang builtin_cling builtin_llvm builtin_openui5 dataframe davix fcgi fftw3 gdml geom gnuinstall gviz http imt mathmore mpi opengl pyroot qt6web roofit root7 runtime_cxxmodules shared soversion spectrum ssl tmva tmva-cpu tmva-cudnn tmva-pymva tpython unuran use_gsl_cblas webgui x11 xml

@pcanal @couet @devajith any ideas how to approach this problem? Forgot to mention that this is root 6.36.00 compiled with c++23.