-
Notifications
You must be signed in to change notification settings - Fork 108
Description
Depending on the compiler I use, sometimes I run into the following error when I try and build a third party SST component that makes use of serialization:
In file included from /home/users/stonea/sst/sst-core/install/include/sst/core/serialization/serialize.h:436:0,
from /home/users/stonea/sst/sst-core/install/include/sst/core/serialization/serializable.h:16,
from /home/users/stonea/sst/sst-core/install/include/sst/core/mempool.h:15,
from /home/users/stonea/sst/sst-core/install/include/sst/core/activity.h:15,
from /home/users/stonea/sst/sst-core/install/include/sst/core/event.h:15,
from /home/users/stonea/sst/sst-core/install/include/sst/core/interfaces/stringEvent.h:15,
from cell.cpp:2:
/home/users/stonea/sst/sst-core/install/include/sst/core/serialization/impl/serialize_variant.h: In lambda function:
/home/users/stonea/sst/sst-core/install/include/sst/core/serialization/impl/serialize_variant.h:108:80: error: parameter packs not expanded with ‘...’:
[](std::variant<Types...>& obj) { obj.template emplace<INDEX>(); }...
^
/home/users/stonea/sst/sst-core/install/include/sst/core/serialization/impl/serialize_variant.h:108:80: note: ‘INDEX’
/home/users/stonea/sst/sst-core/install/include/sst/core/serialization/impl/serialize_variant.h: At global scope:
/home/users/stonea/sst/sst-core/install/include/sst/core/serialization/impl/serialize_variant.h:108:83: error: expansion pattern ‘<lambda>’ contains no argument packs
[](std::variant<Types...>& obj) { obj.template emplace<INDEX>(); }...
This is referring to a template that was added to SST in #1344.
For some reason it seems like it's expecting us to unpack the parameters within the lambda instead of outside of it.
I'm not strong at template metaprogramming, so I tried prompting an LLM tool to "refactor so the thing the parameter pack expression (...) is being applied to is factored out into a separate template" (thinking that doing so would disambiguate where ... is being applied. The tool suggested the following:
template <typename Variant, size_t Index>
constexpr void set_variant_index(Variant& obj) {
obj.template emplace<Index>();
}
template <typename... Types>
template <size_t... INDEX>
constexpr void (*serialize_impl<std::variant<Types...>>::set_index<std::index_sequence<INDEX...>>[])
(std::variant<Types...>&) = {
&set_variant_index<std::variant<Types...>, INDEX>...
};
Which seems to work in the sense that my code now compiles and simulates fine. At a cursory glance this looks like it should be a valid change.
@leekillough, maybe you could take a quick look to see if this suggested fix makes sense or if there's some other simple syntactic fix for this.
I'm compiling on a Cray-EX machine using Cray Clang, here's some version information:
> cc --version
Cray clang version 19.0.0 (cc4d36e4ff3377d45f0e6e892b5dacd82009a0ca)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/cray/pe/cce/19.0.0/cce-clang/x86_64/bin
Build config: +assertions
This is with a build of sst-core that's on the devel branch. Here's the hash: 8ebb1689ed58776c6dd9643fda60a3b4caa09ff2.