Bug 10889 - Convention Fortran matrices mishandled in generics
Summary: Convention Fortran matrices mishandled in generics
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-20 21:46 UTC by 192135
Modified: 2004-01-21 10:41 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-05-31 18:27:46


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 192135 2003-05-20 21:46:00 UTC
 [ Reported to the Debian BTS as report #192135.
   Please CC 192135@bugs.debian.org on replies.
   Log of report can be found at http://bugs.debian.org/192135 ]
	

Consider the following test program.  It prints out
the matrix A twice, using identical code.  However
the second copy of the code is wrapped up in a
generic.  Notice how the rows and columns are swapped
in the second print out?  This only occurs when the
matrix is declared to be of convention Fortran.  This
bug is present in 3.14p to current 3.3.

All the best,

Duncan.

with Ada.Text_IO; use Ada.Text_IO;

procedure Bug is
   subtype Index is Integer range 1 .. 2;

   type Matrix is array (Index, Index) of Integer;
   pragma Convention (Fortran, Matrix);

   generic
      type Matrix is array (Index, Index) of Integer;
   procedure Print_Out (A : Matrix);

   procedure Print_Out (A : Matrix) is
   begin
      for I in A'Range (1) loop
         for J in A'Range (2) loop
            Put (Integer'Image (A (I, J)));
         end loop;
         New_Line;
      end loop;
   end Print_Out;

   procedure Print is new Print_Out (Matrix);

   A : Matrix;
begin
   for I in A'Range (1) loop
      for J in A'Range (2) loop
         A (I, J) := 10 * I + J;
      end loop;
   end loop;

   for I in A'Range (1) loop
      for J in A'Range (2) loop
         Put (Integer'Image (A (I, J)));
      end loop;
      New_Line;
   end loop;

   New_Line;

   Print (A);
end Bug;

Release:
3.3 (Debian) (Debian testing/unstable)

Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
Comment 1 Dara Hazeghi 2003-05-31 18:27:46 UTC
Hello,

I can confirm that this bug is present with gcc 3.2, 3.3 branch and mainline (20030525).

Dara
Comment 2 GCC Commits 2004-01-21 10:35:32 UTC
Subject: Bug 10889

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	charlet@gcc.gnu.org	2004-01-21 10:35:20

Modified files:
	gcc/ada        : 7staprop.adb exp_aggr.adb exp_ch9.adb 
	                 exp_pakd.adb Makefile.in mlib-prj.adb 
	                 prj-tree.adb sem_ch3.adb sem_ch9.adb 
	                 xr_tabls.adb vms_conv.adb ChangeLog 

Log message:
	2004-01-21  Javier Miranda  <miranda@gnat.com>
	
	* exp_aggr.adb (Build_Record_Aggr_Code): Do not build the master
	entity if already built in the current scope.
	
	* exp_ch9.adb (Build_Master_Entity): Do not set the has_master_entity
	reminder in internal scopes. Required for nested limited aggregates.
	
	2004-01-21  Doug Rupp  <rupp@gnat.com>
	
	* Makefile.in (hyphen): New variable, default value '-'. Set to '_' on
	VMS. Replace all occurences of libgnat- and libgnarl- with
	libgnat$(hyphen) and libgnarl$(hyphen).
	Fixed shared library build problem on VMS.
	
	2004-01-21  Robert Dewar  <dewar@gnat.com>
	
	* mlib-prj.adb: Minor reformatting
	
	2004-01-21  Thomas Quinot  <quinot@act-europe.fr>
	
	* prj-tree.adb, 7staprop.adb, vms_conv.adb, xr_tabls.adb: Add missing
	'constant' keywords for declaration of pointers that are not modified.
	
	* exp_pakd.adb: Fix English in comment.
	
	2004-01-21  Ed Schonberg  <schonberg@gnat.com>
	
	PR ada/10889
	* sem_ch3.adb (Analyze_Subtype_Declaration): For an array subtype,
	copy all attributes of the parent, including the foreign language
	convention.
	
	2004-01-21  Sergey Rybin  <rybin@act-europe.fr>
	
	PR ada/10565
	* sem_ch9.adb (Analyze_Delay_Alternative): Add expression type check
	for 'delay until' statement.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/7staprop.adb.diff?cvsroot=gcc&r1=1.8&r2=1.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/exp_aggr.adb.diff?cvsroot=gcc&r1=1.13&r2=1.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/exp_ch9.adb.diff?cvsroot=gcc&r1=1.12&r2=1.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/exp_pakd.adb.diff?cvsroot=gcc&r1=1.8&r2=1.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/Makefile.in.diff?cvsroot=gcc&r1=1.65&r2=1.66
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/mlib-prj.adb.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/prj-tree.adb.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/sem_ch3.adb.diff?cvsroot=gcc&r1=1.28&r2=1.29
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/sem_ch9.adb.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/xr_tabls.adb.diff?cvsroot=gcc&r1=1.8&r2=1.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/vms_conv.adb.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ada/ChangeLog.diff?cvsroot=gcc&r1=1.431&r2=1.432

Comment 3 Arnaud Charlet 2004-01-21 10:41:13 UTC
Fixed in mainline.

Arno