[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867 Eric Botcazou changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|9.5 |11.0 --- Comment #15 from Eric Botcazou --- .
[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867 simon at pushface dot org changed: What|Removed |Added CC||simon at pushface dot org --- Comment #14 from simon at pushface dot org --- (In reply to Nicolas Boulenguez from comment #0) > Hello. > With GCC-6 (Debian 6.0.1-2) 6.0.1 20160423 (prerelease), > compiling the following package with "gcc-6 -c p.adb" fails: > p.adb:4:20: access discriminant in return aggregate would be a dangling > reference > The code compiles > - if the "generic" line is removed > - or if ".all" is inserted between "Position" and ".Item'Access" > I am not sure whether returning this reference is allowed by the Ada > Reference Manual, > but the semantics of "generic" and ".all" should certainly not affect the > answer. GCC 11.1.0, x86_64-apple-darwin on macOS 11.6 (Big Sur): This compiles without error, and the example below executes correctly. with P; with Ada.Text_IO; procedure P_Test is package Q is new P; R : aliased Q.R := (Item => 42); T : Q.T := Q.F (R'Access); begin Ada.Text_IO.Put_Line (T.D.all'Image); end P_Test;
[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867 --- Comment #13 from yuta tomino --- Sorry, perhaps my example is illegal in Ada 2012. "aliased" is required to return a reference of a part of the parameter. Randy explained the change in https://groups.google.com/g/comp.lang.ada/c/7dw7Oqi8lIk/m/5NUBhFN8DQAJ . (I wonder if it was legal before Ada 2005?? Because aliased parameter is added in Ada 2012 and the relevant text has been changed by AI05-0234-1.) I think Nicolas's example is always legal. Thanks.
[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867 Richard Biener changed: What|Removed |Added Target Milestone|9.4 |9.5 --- Comment #12 from Richard Biener --- GCC 9.4 is being released, retargeting bugs to GCC 9.5.
[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867 Jakub Jelinek changed: What|Removed |Added Target Milestone|8.5 |9.4 --- Comment #11 from Jakub Jelinek --- GCC 8 branch is being closed.