https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122860
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:00ac906e7a9a58811fc3cebc9d389d87b62e8c83 commit r16-5835-g00ac906e7a9a58811fc3cebc9d389d87b62e8c83 Author: Jakub Jelinek <[email protected]> Date: Tue Dec 2 14:36:49 2025 +0100 c++: Diagnose taking addresses of hard reg vars in their initializers [PR122860] DECL_HARD_REGISTER is set only in cp_finish_decl together with set_user_assembler_name. If user attempts to take address of such a var later, cxx_mark_addressable diagnoses it. But if as in the following testcase the address is taken in its initializer, we just ICE during expansion. The following patch fixes it by emitting errors if TREE_ADDRESABLE at the point we'd otherwise set DECL_HARD_REGISTER on it. 2025-12-02 Jakub Jelinek <[email protected]> PR c++/122860 * decl.cc (make_rtl_for_nonlocal_decl): Diagnose taking address of a hard register decl in its initializer. (cp_finish_decl): Likewise. * g++.dg/ext/pr122860.C: New test.
