https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114592
Magne Oestlyngen <mskybert+gccbugs at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mskybert+gccbugs at gmail dot com --- Comment #1 from Magne Oestlyngen <mskybert+gccbugs at gmail dot com> --- Smaller minimal example: #include <string> #include <variant> #include <vector> void fails(std::vector<std::variant<int, std::string>>& vec) { vec.push_back(1); } If vector is local to the function instead of input-param, there is no warning.