https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org, | |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org, | |mpolacek at gcc dot gnu.org, | |redi at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- With -fpic it actually rejects both static_asserts. In all the cases, it is symtab_node::equal_address_to that attempts to decide if the two VAR_DECLs need to be the same or distinct or unknown. Without templates and without -fpic that function returns true, because both are defined locally and we can easily decide that they must be different, but with -fpic, the generic code allows them to be interposed and fails. Even without -fpic, for templates the variables are DECL_COMDAT and thus not really known if defined by the current or some other TU. No idea if C++ standard says anything here and constexpr evaluation shouldn't use some different rules (or in addition to what the generic code says).