https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123832
--- Comment #1 from Liam Powell <liam at liampwll dot com> ---
If I'm understanding the below -gnatG output correctly (which I may not be)
then S33b is getting overwritten by R50b but N47b is still trying to access it
by address.
B24b : declare
N47b : aliased system__finalization_primitives__master_node;
begin
R50b : constant example__B24b__A51b := example__Oconcat__2 ((
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
example__to_virtual_string (
do
S33b : ada__strings__text_buffers__unbounded__buffer_type;
$system__finalization_primitives__attach_object_to_node (
S33b'address,
ada__strings__text_buffers__unbounded__buffer_typeFD'
unrestricted_access, N47b);
in R34b end
))'reference;
null;
$system__finalization_primitives__finalize_object (N47b,
ada__strings__text_buffers__unbounded__buffer_typeFD'
unrestricted_access);
end B24b;
Build_Image_Call has this comment and I assume Destroy (S) means finalize,
meaning that it should not go to N47b. How to fix that is beyond what I can
figure out. Hoisting the variable by using Insert_Actions fixes the issue, but
that then violates 7.6.1(4).
-- For T'[[Wide_]Wide_]Image (X) Generate an Expression_With_Actions
-- node:
--
-- do
-- S : Buffer;
-- U_Type'Put_Image (S, X);
-- Result : constant [[Wide_]Wide_]String :=
-- [[Wide_[Wide_]]Get (S);
-- Destroy (S);
-- in Result end