[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 --- Comment #7 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:abc79c6498a99e9c39e6056f432796c6dde3a887 commit r10-6628-gabc79c6498a99e9c39e6056f432796c6dde3a887 Author: Jason Merrill Date: Thu Feb 13 16:42:04 2020 +0100 c++: Fix static local vars in extern "C". Since my patch for PR 91476 moved visibility determination sooner, a local static in a vague linkage function now gets TREE_PUBLIC set before retrofit_lang_decl calls set_decl_linkage, which was making decl_linkage think that it has external linkage. It still has no linkage according to the standard. gcc/cp/ChangeLog 2020-02-13 Jason Merrill PR c++/93643 PR c++/91476 * tree.c (decl_linkage): Always lk_none for locals.
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 --- Comment #6 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:25d62480c89d6db90a66ba69f6dbaa820a1ac90b commit r10-6307-g25d62480c89d6db90a66ba69f6dbaa820a1ac90b Author: Jason Merrill Date: Tue Jan 28 15:15:20 2020 -0500 c++: Fix guard variable and attribute weak. My patch for PR 91476 worked for decls that are implicitly comdat/weak due to C++ linkage rules, but broke variables explicitly marked weak. PR c++/93477 PR c++/91476 * decl2.c (copy_linkage): Do copy DECL_ONE_ONLY and DECL_WEAK.
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 Jason Merrill changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #5 from Jason Merrill --- Fixed for 9.3/10.
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 --- Comment #4 from CVS Commits --- The releases/gcc-9 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:3384aa7af4c4ce193f59d086f507812b88caf113 commit r9-8151-g3384aa7af4c4ce193f59d086f507812b88caf113 Author: Jason Merrill Date: Mon Jan 20 14:09:03 2020 -0500 PR c++/91476 - anon-namespace reference temp clash between TUs. * call.c (make_temporary_var_for_ref_to_temp): Clear TREE_PUBLIC if DECL is in the anonymous namespace.
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 --- Comment #3 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:8158a4640819dbb3210326e37786fb874f450272 commit r10-6110-g8158a4640819dbb3210326e37786fb874f450272 Author: Jason Merrill Date: Mon Jan 20 13:27:10 2020 -0500 PR c++/91476 - anon-namespace reference temp clash between TUs. The problem in the PR was that make_temporary_var_for_ref_to_temp ran before determine_visibility, so when we copied the linkage of the reference variable it had not yet been restricted by its anonymous namespace context, so the temporary wrongly ended up with TREE_PUBLIC set. The natural solution is to run determine_visibility earlier. But that needs to happen after maybe_commonize_var increases the linkage of some local variables, and on targets without weak symbol support, that function does different things based on the results of check_initializer, which is what calls make_temporary_var_for_ref_to_temp. To break this circular dependency I'm calling maybe_commonize_var early, and then again later if the target doesn't support weak symbols. It also occurred to me that make_temporary_var_for_ref_to_temp wasn't handling DECL_VISIBILITY at all, and verified that we were doing the wrong thing. So I've combined the linkage-copying code from there and two other places. * decl2.c (copy_linkage): Factor out of get_guard. * call.c (make_temporary_var_for_ref_to_temp): Use it. * decl.c (cp_finish_decomp): Use it. (cp_finish_decl): determine_visibility sooner.
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 Jonathan Wakely changed: What|Removed |Added Keywords|needs-bisection | CC||jason at gcc dot gnu.org --- Comment #2 from Jonathan Wakely --- Started to fail with r268252: PR c++/89001 - mangling of reference temporaries It used to be the case that the mangled name of a reference temporary didn't need to be standardized, because all access would be through the reference. But now constant expressions can look through references and so different translation units need to agree on the address of a temporary in the initializer of a reference with vague linkage. * cp-tree.h (struct saved_scope): Add ref_temp_count. (current_ref_temp_count): New macro. * mangle.c (mangle_ref_init_variable): Use it. * typeck2.c (store_init_value): Clear it. * call.c (make_temporary_var_for_ref_to_temp): Copy public and comdat.
[Bug c++/91476] [9/10 Regression] const reference variables sharing the same name in two anonymous namespaces cause a multiple definition error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91476 Richard Biener changed: What|Removed |Added Priority|P3 |P2 Status|UNCONFIRMED |NEW Known to work||8.3.0 Keywords||ABI, link-failure, ||needs-bisection, wrong-code Last reconfirmed||2019-08-19 Ever confirmed|0 |1 Summary|const reference variables |[9/10 Regression] const |sharing the same name in|reference variables sharing |two anonymous namespaces|the same name in two |cause a multiple definition |anonymous namespaces cause |error |a multiple definition error Target Milestone|--- |9.3 Known to fail||9.1.0 --- Comment #1 from Richard Biener --- Confirmed.