public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation
@ 2023-11-30 12:27 simon at pushface dot org
  2023-11-30 13:57 ` [Bug ada/112781] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: simon at pushface dot org @ 2023-11-30 12:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112781
           Summary: [13?/14 regression] ICE in generic instantiation
           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: ---

Created attachment 56727
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56727&action=edit
Reproducer: to be gnatchopped

I'm not sure this is in fact a regression in 13; with 13.1.0, the
program builds, but when run reports

    $ ./test
    Hello World

    raised PROGRAM_ERROR : test.adb:4 finalize/adjust raised exception

With 14.0.0, built from LATEST, we get a bug box:

$ gnatmake test.adb 
gcc -c test.adb
+===========================GNAT BUG DETECTED==============================+
| 14.0.0 20231126 (experimental) (x86_64-apple-darwin21) Assert_Failure
sem_ch3.adb:16970|
| Error detected at example.ads:3:9 [test.adb:16:4]                        |
| Compiling test.adb                                                       |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact command that you entered.                              |
| Also include sources listed below.                                       |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

test.adb
example.ads

compilation abandoned
gnatmake: "test.adb" compilation error

Reproducer (to be gnat chopped) attached.

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

* [Bug ada/112781] [13?/14 regression] ICE in generic instantiation
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
@ 2023-11-30 13:57 ` rguenth at gcc dot gnu.org
  2023-12-04 17:24 ` [Bug ada/112781] [13/14 " ebotcazou at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-30 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.3

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

* [Bug ada/112781] [13/14 regression] ICE in generic instantiation
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
  2023-11-30 13:57 ` [Bug ada/112781] " rguenth at gcc dot gnu.org
@ 2023-12-04 17:24 ` ebotcazou at gcc dot gnu.org
  2023-12-05  0:51 ` ebotcazou at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-12-04 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[13?/14 regression] ICE in  |[13/14 regression] ICE in
                   |generic instantiation       |generic instantiation
                 CC|                            |ebotcazou at gcc dot gnu.org
   Last reconfirmed|                            |2023-12-04
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
At least the program runs quietly when compiled with earlier compilers.

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

* [Bug ada/112781] [13/14 regression] ICE in generic instantiation
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
  2023-11-30 13:57 ` [Bug ada/112781] " rguenth at gcc dot gnu.org
  2023-12-04 17:24 ` [Bug ada/112781] [13/14 " ebotcazou at gcc dot gnu.org
@ 2023-12-05  0:51 ` ebotcazou at gcc dot gnu.org
  2023-12-05 11:39 ` [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface ebotcazou at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-12-05  0:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Investigating.

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

* [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
                   ` (2 preceding siblings ...)
  2023-12-05  0:51 ` ebotcazou at gcc dot gnu.org
@ 2023-12-05 11:39 ` ebotcazou at gcc dot gnu.org
  2024-01-09  9:49 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-12-05 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[13/14 regression] ICE in   |[13/14 regression] internal
                   |generic instantiation       |error on function call
                   |                            |returning extension of
                   |                            |limited interface

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
The testcase triggers 3 different assertion failures, the first 2 are benign
but not the third, which leads to the wrong code with GCC 13.x (the workaround
for the latter is to remove the "limited" keyword everywhere).

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

* [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
                   ` (3 preceding siblings ...)
  2023-12-05 11:39 ` [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface ebotcazou at gcc dot gnu.org
@ 2024-01-09  9:49 ` cvs-commit at gcc dot gnu.org
  2024-01-09  9:50 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-09  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:436ce7a3510000e0939094592fc12353e17527f1

commit r14-7031-g436ce7a3510000e0939094592fc12353e17527f1
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Jan 9 10:46:23 2024 +0100

    Fix internal error on function call returning extension of limited
interface

    This is a regression present on the mainline and 13 branch, in the form of
a
    series of internal errors (3) on a function call returning the extension of
    a limited interface.

    This is only a partial fix for the first two assertion failures; the third
    one is the most problematic and will be dealt with separately.

    The first issue is in Instantiate_Type, where we use Base_Type in a
specific
    case to compute the ancestor of a derived type, which will later trigger
the
    assertion on line 16960 of sem_ch3.adb since Parent_Base and Generic_Actual
    are the same node.  This is changed to use Etype like in other cases
around.

    The second issue is an unprotected use of Designated_Type on type T in
    Analyze_Explicit_Dereference, while another use in an equivalent context
    is guarded by Is_Access_Type a few lines above.

    gcc/ada
            PR ada/112781
            * sem_ch12.adb (Instantiate_Type): Use Etype instead of Base_Type
            consistently to retrieve the ancestor for a derived type.
            * sem_ch4.adb (Analyze_Explicit_Dereference): Test Is_Access_Type
            consistently before accessing Designated_Type.

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

* [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
                   ` (4 preceding siblings ...)
  2024-01-09  9:49 ` cvs-commit at gcc dot gnu.org
@ 2024-01-09  9:50 ` cvs-commit at gcc dot gnu.org
  2024-01-09 10:07 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-09  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:275de3505e6c5b81bb8060acc5194dac8f5732b5

commit r13-8203-g275de3505e6c5b81bb8060acc5194dac8f5732b5
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Jan 9 10:46:23 2024 +0100

    Fix internal error on function call returning extension of limited
interface

    This is a regression present on the mainline and 13 branch, in the form of
a
    series of internal errors (3) on a function call returning the extension of
    a limited interface.

    This is only a partial fix for the first two assertion failures; the third
    one is the most problematic and will be dealt with separately.

    The first issue is in Instantiate_Type, where we use Base_Type in a
specific
    case to compute the ancestor of a derived type, which will later trigger
the
    assertion on line 16960 of sem_ch3.adb since Parent_Base and Generic_Actual
    are the same node.  This is changed to use Etype like in other cases
around.

    The second issue is an unprotected use of Designated_Type on type T in
    Analyze_Explicit_Dereference, while another use in an equivalent context
    is guarded by Is_Access_Type a few lines above.

    gcc/ada
            PR ada/112781
            * sem_ch12.adb (Instantiate_Type): Use Etype instead of Base_Type
            consistently to retrieve the ancestor for a derived type.
            * sem_ch4.adb (Analyze_Explicit_Dereference): Test Is_Access_Type
            consistently before accessing Designated_Type.

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

* [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
                   ` (5 preceding siblings ...)
  2024-01-09  9:50 ` cvs-commit at gcc dot gnu.org
@ 2024-01-09 10:07 ` cvs-commit at gcc dot gnu.org
  2024-01-09 10:14 ` cvs-commit at gcc dot gnu.org
  2024-01-09 10:14 ` ebotcazou at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-09 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:8f80b9f0904eb98b41913068ce7dc021c2f35ecc

commit r14-7032-g8f80b9f0904eb98b41913068ce7dc021c2f35ecc
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Jan 9 11:06:23 2024 +0100

    Fix internal error on function call returning extension of limited
interface

    The problem occurs when this function call is the expression of a return in
    a function returning the limited interface; in this peculiar case, there is
    a mismatch between the callee, which has BIP formals but is not a BIP call,
    and the caller, which is a BIP function, that is spotted by an assertion.

    This is fixed by restoring the semantics of
Is_Build_In_Place_Function_Call,
    which returns again true only for calls to BIP functions, introducing the
    Is_Function_Call_With_BIP_Formals predicate, which also returns true for
    calls to functions with BIP formals that are not BIP functions, and moving
    down the assertion in Expand_Simple_Function_Return.

    gcc/ada/
            PR ada/112781
            * exp_ch6.ads (Is_Build_In_Place_Function): Adjust description.
            * exp_ch6.adb (Is_True_Build_In_Place_Function_Call): Delete.
            (Is_Function_Call_With_BIP_Formals): New predicate.
            (Is_Build_In_Place_Function_Call): Restore original semantics.
            (Expand_Call_Helper): Adjust conditions guarding the calls to
            Add_Dummy_Build_In_Place_Actuals to above renaming.
            (Expand_N_Extended_Return_Statement): Adjust to above renaming.
            (Expand_Simple_Function_Return): Likewise.  Move the assertion
            to after the transformation into an extended return statement.
            (Make_Build_In_Place_Call_In_Allocator): Remove unreachable code.
            (Make_Build_In_Place_Call_In_Assignment): Likewise.

    gcc/testsuite/
            * gnat.dg/bip_prim_func2.adb: New test.
            * gnat.dg/bip_prim_func2_pkg.ads, gnat.dg/bip_prim_func2_pkg.adb:
            New helper package.

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

* [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
                   ` (6 preceding siblings ...)
  2024-01-09 10:07 ` cvs-commit at gcc dot gnu.org
@ 2024-01-09 10:14 ` cvs-commit at gcc dot gnu.org
  2024-01-09 10:14 ` ebotcazou at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-09 10:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:36ddb5230f56a30317630a928dd73ed46eda03f1

commit r13-8205-g36ddb5230f56a30317630a928dd73ed46eda03f1
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Jan 9 11:06:23 2024 +0100

    Fix internal error on function call returning extension of limited
interface

    The problem occurs when this function call is the expression of a return in
    a function returning the limited interface; in this peculiar case, there is
    a mismatch between the callee, which has BIP formals but is not a BIP call,
    and the caller, which is a BIP function, that is spotted by an assertion.

    This is fixed by restoring the semantics of
Is_Build_In_Place_Function_Call,
    which returns again true only for calls to BIP functions, introducing the
    Is_Function_Call_With_BIP_Formals predicate, which also returns true for
    calls to functions with BIP formals that are not BIP functions, and moving
    down the assertion in Expand_Simple_Function_Return.

    gcc/ada/
            PR ada/112781
            * exp_ch6.ads (Is_Build_In_Place_Function): Adjust description.
            * exp_ch6.adb (Is_True_Build_In_Place_Function_Call): Delete.
            (Is_Function_Call_With_BIP_Formals): New predicate.
            (Is_Build_In_Place_Function_Call): Restore original semantics.
            (Expand_Call_Helper): Adjust conditions guarding the calls to
            Add_Dummy_Build_In_Place_Actuals to above renaming.
            (Expand_N_Extended_Return_Statement): Adjust to above renaming.
            (Expand_Simple_Function_Return): Likewise.  Move the assertion
            to after the transformation into an extended return statement.
            (Make_Build_In_Place_Call_In_Allocator): Remove unreachable code.
            (Make_Build_In_Place_Call_In_Assignment): Likewise.

    gcc/testsuite/
            * gnat.dg/bip_prim_func2.adb: New test.
            * gnat.dg/bip_prim_func2_pkg.ads, gnat.dg/bip_prim_func2_pkg.adb:
            New helper package.

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

* [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface
  2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
                   ` (7 preceding siblings ...)
  2024-01-09 10:14 ` cvs-commit at gcc dot gnu.org
@ 2024-01-09 10:14 ` ebotcazou at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-01-09 10:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Thanks for reporting the problem.

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

end of thread, other threads:[~2024-01-09 10:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 12:27 [Bug ada/112781] New: [13?/14 regression] ICE in generic instantiation simon at pushface dot org
2023-11-30 13:57 ` [Bug ada/112781] " rguenth at gcc dot gnu.org
2023-12-04 17:24 ` [Bug ada/112781] [13/14 " ebotcazou at gcc dot gnu.org
2023-12-05  0:51 ` ebotcazou at gcc dot gnu.org
2023-12-05 11:39 ` [Bug ada/112781] [13/14 regression] internal error on function call returning extension of limited interface ebotcazou at gcc dot gnu.org
2024-01-09  9:49 ` cvs-commit at gcc dot gnu.org
2024-01-09  9:50 ` cvs-commit at gcc dot gnu.org
2024-01-09 10:07 ` cvs-commit at gcc dot gnu.org
2024-01-09 10:14 ` cvs-commit at gcc dot gnu.org
2024-01-09 10:14 ` 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).