https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127836
Bug ID: 127836
Summary: [reflection] undefined reference to constexpr
structured binding of tuple containing vector of
std::meta::info
Product: gcc
Version: 16.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: edoardo762 at gmail dot com
Target Milestone: ---
the following code
```
#include <meta>
#include <vector>
int main() {
static constexpr auto vals = [] consteval {
static constexpr auto [a, b] = [] {
std::vector<std::meta::info> res;
int res2 = 0;
return std::make_pair(res, res2);
}();
return 0;
}();
return 0;
}
```
when compiled with `g++ main.cpp -std=c++26 -freflection -O0`, fails linking
with a
`undefined reference to `main::{lambda()#1}::operator()() const::[a, b]'`
error.
I tagged with `[reflection]` because i get this linking error when using
std::meta::info, and the snippet is a reduction of code performing
metaprogramming (the pair was first taking the vector passed through
define_static_array, but for this link error example it fails with the same
error regardless of it being present). If the bug isn't specific to reflection,
feel free to update the title accordingly.
>From the description, might be similar to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108474 (?)
I also tried the same code on godbolt using the gcc available present there,
but it doesn't seem to happen, so i'm dubious if this could be caused by
something else.
This is the GCC version i'm using, from arch linux
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/16/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-gcc-major-version-only
--with-linker-hash-style=gnu --with-system-zlib --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-fixincludes --disable-libssp
--disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.2.1 20260810 (GCC)