https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24375
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
The reason is the in-class initializer. Move it and the previous definition
changes.
prog.cc:8:21: error: redefinition of 'const int foo<int>::u'
const int foo<int>::u;
^
prog.cc:6:11: note: 'const int foo<int>::u' previously defined here
const int foo<int>::u = 0;
^~~~~~~~
I think it may be because of this code:
/* Merge the initialization information. */
if (DECL_INITIAL (newdecl) == NULL_TREE
&& DECL_INITIAL (olddecl) != NULL_TREE)
{
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
}
}