[Bug c++/126472] Wrong initialization (zero-initialization) in initializer_list

"ppalka at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126472

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |---

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
A workaround is to make the elements of the initializer list all non-constant,
e.g.

int n = 42;
const InitList data {
        std::tuple<std::optional<std::vector<int>>, int>(
                std::optional<std::vector<int>>(std::vector<int>(1, 42)),
                n),

        std::tuple<std::optional<std::vector<int>>, int>(
                std::optional<std::vector<int>>(),
                n),
};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.