https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35330
--- Comment #12 from Kai Tietz <ktietz at gcc dot gnu.org> --- issue seems to be that in declare_weak we don't check that DECL is actually either a function, or a variable declaration. Fix would be to add an error-message in declare_weak (). Index: varasm.c =================================================================== @@ -5398,6 +5399,12 @@ void declare_weak (tree decl) { gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !TREE_ASM_WRITTEN (decl)); + if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) + { + error ("weak declaration of %q+D has to be either a function," + " or a variable declaration", decl); + return; + } if (! TREE_PUBLIC (decl)) error ("weak declaration of %q+D must be public", decl); else if (!TARGET_SUPPORTS_WEAK)