public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/112461] New: [14 regression] Simple return inside extended return loses updates to return object value
@ 2023-11-09 15:01 simon at pushface dot org
  2023-11-10  8:16 ` [Bug ada/112461] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: simon at pushface dot org @ 2023-11-09 15:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112461

            Bug ID: 112461
           Summary: [14 regression] Simple return inside extended return
                    loses updates to return object value
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

In a complicated extended return[1] with this structure

   --  Calculate the sum of the natural numbers up to & including the
   --  given limit.
   function Add (Up_To : Natural) return Natural is
      Round : Natural := 0;
   begin
      return Result : Natural := 0 do
         loop
            Result := Result + Round;
            if Round = Up_To then
               return;
            end if;
            Round := Round + 1;
         end loop;
      end return;
   end Add;

what was returned was the equivalent of the initial value (here, 0) rather 
than the value as updated in the loop (NB! this simple loop doesn’t fail, 
I only include it as an example, since I don’t have a simple reproducer).

The problem was introduced after 20231008.

[1]
https://github.com/alire-project/alire/blob/a69ac7c7a24590bdfe1ca77bcb60386551989696/src/alire/alire-properties-from_toml.adb#L14

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/112461] [14 regression] Simple return inside extended return loses updates to return object value
  2023-11-09 15:01 [Bug ada/112461] New: [14 regression] Simple return inside extended return loses updates to return object value simon at pushface dot org
@ 2023-11-10  8:16 ` rguenth at gcc dot gnu.org
  2023-11-10 10:05 ` [Bug ada/112461] [14 regression] premature finalization with nested return inside extended one ebotcazou at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-10  8:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112461

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/112461] [14 regression] premature finalization with nested return inside extended one
  2023-11-09 15:01 [Bug ada/112461] New: [14 regression] Simple return inside extended return loses updates to return object value simon at pushface dot org
  2023-11-10  8:16 ` [Bug ada/112461] " rguenth at gcc dot gnu.org
@ 2023-11-10 10:05 ` ebotcazou at gcc dot gnu.org
  2023-11-10 10:06 ` ebotcazou at gcc dot gnu.org
  2023-12-04 10:05 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-11-10 10:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112461

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[14 regression] Simple      |[14 regression] premature
                   |return inside extended      |finalization with nested
                   |return loses updates to     |return inside extended one
                   |return object value         |
     Ever confirmed|0                           |1
                 CC|                            |ebotcazou at gcc dot gnu.org
   Last reconfirmed|                            |2023-11-10
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Yes, by commit 2e135bdb28d386b0cda2ee7e35338ad06136042d, but the issue was
preexisting if the return type is limited.  The fix is upcoming.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/112461] [14 regression] premature finalization with nested return inside extended one
  2023-11-09 15:01 [Bug ada/112461] New: [14 regression] Simple return inside extended return loses updates to return object value simon at pushface dot org
  2023-11-10  8:16 ` [Bug ada/112461] " rguenth at gcc dot gnu.org
  2023-11-10 10:05 ` [Bug ada/112461] [14 regression] premature finalization with nested return inside extended one ebotcazou at gcc dot gnu.org
@ 2023-11-10 10:06 ` ebotcazou at gcc dot gnu.org
  2023-12-04 10:05 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-11-10 10:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112461

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ebotcazou at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/112461] [14 regression] premature finalization with nested return inside extended one
  2023-11-09 15:01 [Bug ada/112461] New: [14 regression] Simple return inside extended return loses updates to return object value simon at pushface dot org
                   ` (2 preceding siblings ...)
  2023-11-10 10:06 ` ebotcazou at gcc dot gnu.org
@ 2023-12-04 10:05 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-12-04 10:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112461

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
https://gcc.gnu.org/g:f6bbf84ec759f203251c6c5a0dec8344f17cc614

commit r14-5909-gf6bbf84ec759f203251c6c5a0dec8344f17cc614
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Nov 8 23:29:01 2023 +0100

    ada: Fix premature finalization for nested return within extended one

    The return object is incorrectly finalized when the nested return is taken,
    because the special flag attached to the return object is not updated.

    gcc/ada/
            * exp_ch6.adb (Build_Flag_For_Function): New function made up of
the
            code building the special flag for return object present...
            (Expand_N_Extended_Return_Statement): ...in there.  Replace the
code
            with a call to Build_Flag_For_Function.  Add assertion for the
flag.
            (Expand_Non_Function_Return): For a nested return, if the return
            object needs finalization actions, update the special flag.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-04 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-09 15:01 [Bug ada/112461] New: [14 regression] Simple return inside extended return loses updates to return object value simon at pushface dot org
2023-11-10  8:16 ` [Bug ada/112461] " rguenth at gcc dot gnu.org
2023-11-10 10:05 ` [Bug ada/112461] [14 regression] premature finalization with nested return inside extended one ebotcazou at gcc dot gnu.org
2023-11-10 10:06 ` ebotcazou at gcc dot gnu.org
2023-12-04 10:05 ` ebotcazou at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).