https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80351
--- Comment #4 from Pokechu22 <pokechu022+gccbugzilla at gmail dot com> --- This also affects const variables, not just constexpr ones. See https://godbolt.org/z/5coadhr8a. The source of the issue is that the type is not complete the first time when cp_apply_type_quals_to_decl (in cp/typeck.cc) is called by cp_finish_decl (in cp/decl.cc); since it is not complete, cp_apply_type_quals_to_decl removes the const qualifier on the assumption that cp_finish_decl will later add it, but it's too late for that. (cp_apply_type_quals_to_decl is also called earlier on by grokdeclarator (cp/decl.cc) where that assumption is valid). The type is already complete when a second variable is declared, which is why the warning only appears once. Presumably, initializer lists are the only type where auto can deduce to something that hasn't been completed yet (though I'm not 100% sure of this). This change fixes the issue: ``` --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@@ -8098,7 -8098,7 +8098,7 @@@ cp_finish_decl (tree decl, tree init, b TREE_TYPE (decl) = error_mark_node; return; } - cp_apply_type_quals_to_decl (cp_type_quals (type), decl); + cp_apply_type_quals_to_decl (cp_type_quals (complete_type (type)), decl); } if (ensure_literal_type_for_constexpr_object (decl) == error_mark_node) ``` I am working on sending in a proper patch with testcases. (I assume I will not need to fill out the contributing agreement for a change this small.)