[Bug ada/21338] New: gcc with -c -gnatc and -gnatt generates Stack Overflow

2005-05-02 Thread karl at grebyn dot com
Attached files generate Stack Overflow when compiled with -c -gnatc and -gnatt.
 With only -c and either of the other two, no problems.

Problem also exists in prior 4.0 snapshot, and as I recall, in the 4.0 release
as well.

package Toplevel is

end Toplevel;
package Toplevel.Intermediate is

  An_Prefix   : constant String := "An_Prefix";
  Al_Prefix   : constant String := "Al_Prefix";

end Toplevel.Intermediate;
with Toplevel.Intermediate;

package Toplevel.Midlevel is

  Al_Prefix : String renames Toplevel.Intermediate.Al_Prefix;
  An_Prefix : String renames Toplevel.Intermediate.An_Prefix;

end Toplevel.Midlevel;
package Toplevel.Midlevel.Bottom is

   function Blank return Boolean;

end Toplevel.Midlevel.Bottom;

8:23 1290 submit: mkdir /tmp/jjj
8:24 1291 submit: cat *.ads > /tmp/jjj/files
8:24 1292 submit: cd /tmp/jjj
8:24 1293 jjj: l
total 4
-rw-r--r--  1 karl karl 502 May  2 08:24 files
8:24 1294 jjj: gnatchop files
splitting files into:
   toplevel.ads
   toplevel-intermediate.ads
   toplevel-midlevel.ads
   toplevel-midlevel-bottom.ads
8:24 1295 jjj: l
total 20
-rw-r--r--  1 karl karl 502 May  2 08:24 files
-rw-r--r--  1 karl karl  35 May  2 08:24 toplevel.ads
-rw-r--r--  1 karl karl 158 May  2 08:24 toplevel-intermediate.ads
-rw-r--r--  1 karl karl 207 May  2 08:24 toplevel-midlevel.ads
-rw-r--r--  1 karl karl 102 May  2 08:24 toplevel-midlevel-bottom.ads
8:24 1296 jjj: !gcc
gcc -c -gnatc -gnatt *.ads
+===GNAT BUG DETECTED==+
| 4.0.1 20050430 (prerelease) (i686-pc-linux-gnu) Storage_Error stack overflow
(or erroneous memory access)|
| Error detected at system.ads:151:5   |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.|
| Include the entire contents of this bug box in the report.   |
| Include the exact gcc or gnatmake command that you entered.  |
| Also include sources listed below in gnatchop format |
| (concatenated together with no headers between files).   |
+==+

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.

toplevel-midlevel-bottom.ads
toplevel-midlevel.ads
toplevel.ads
toplevel-intermediate.ads

compilation abandoned
8:24 1297 jjj: . ~/.cshrc.new
8:25 1298 jjj: which gcc
/home/karl/gcc-4.1-20050501/bin/gcc
8:25 1299 jjj: !gcc
gcc -c -gnatc -gnatt *.ads
+===GNAT BUG DETECTED==+
| 4.1.0 20050501 (experimental) (i686-pc-linux-gnu) Storage_Error stack overflow
(or erroneous memory access)|
| Error detected at system.ads:152:5   |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.|
| 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 gcc or gnatmake command that you entered.  |
| Also include sources listed below in gnatchop format |
| (concatenated together with no headers between files).   |
+==+

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.

toplevel-midlevel-bottom.ads
toplevel-midlevel.ads
toplevel.ads
toplevel-intermediate.ads

compilation abandoned
8:25 1300 jjj: gcc -c -gnatc *.ads
8:26 1301 jjj: gcc -c *.ads
cannot generate code for file toplevel-midlevel-bottom.ads (package spec)
to check package spec for errors, use -gnatc
8:26 1302 jjj: gcc -c -gnatt *.ads
cannot generate code for file toplevel-midlevel-bottom.ads (package spec)
to check package spec for errors, use -gnatc
8:26 1303 jjj:

-- 
   Summary: gcc with -c -gnatc and -gnatt generates Stack Overflow
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: karl at grebyn dot com
CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21338


[Bug ada/18085] New: [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 2.4.20-8, Red Hat 9.0

2004-10-20 Thread karl at grebyn dot com
This program source is modified (additional print statements) from:
   
http://gcc.gnu.org/onlinedocs/gcc-3.4.2/gnat_ugn_unw/A-Simple-Example.html#A-Simple-Example

An example of interoperating C++ and Ada code.  The results seem to
indicate that the calls between the two languages are working OK, but
that the parameter passing isn't.  I guess that indicates something in the ABI,
perhaps?

The final value in A::method2 should be 3030, and the intermediate
values in the Ada calls are wrong.

$ gcc -v
Reading specs from /opt/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
Configured with: ./configure --prefix=/opt --enable-languages=ada,c,c++
Thread model: posix
gcc version 3.4.2
$ uname -a
Linux ezekiel 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux
$ cat /etc/issue
Red Hat Linux release 9 (Shrike)
Kernel \r on an \m

$./cpp_main
in A::A, a_value = 1010
=== in A::method2, a_value was = 1010
in Ada_Method2, O_Value = 134582632
in Ada_Method2, A_Value =-1073749612
in A::method1, a_value = 2020
in Ada_Method2, O_Value = 134582632
in Ada_Method2, A_Value =-1073749612
in Ada_Method2, O_Value = 134582632
in Ada_Method2, A_Value = 3030
=== in A::method2, a_value = 2020
$ cat compile
#! /bin/csh
# compilation script to evidence the bug
gnatmake -c simple_cpp_interface
c++ -c cpp_main.C
c++ -c ex7.C
gnatbind -n simple_cpp_interface
gnatlink simple_cpp_interface -o cpp_main --LINK=c++  -lstdc++ ex7.o cpp_main.o
$ cat *.C *.h *.ad?
// cpp_main.C start

#include "ex7.h"
#include 

extern "C" {
  void adainit (void);
  void adafinal (void);
  void method1 (A *t);
}

void method1 (A *t)
{
t->method1 ();
}

int main ()
{
  A obj;
  adainit ();
  obj.method2 (3030);
  adafinal ();
}

// cpp_main.C end
//ex7.C start

#include "ex7.h"
#include 

extern "C" { void ada_method2 (A *t, int v);}

void A::method1 (void)
{
  a_value = 2020;
  printf ("in A::method1, a_value = %d \n",a_value);

}

void A::method2 (int v)
{
  printf ("=== in A::method2, a_value was = %d \n",a_value);
  ada_method2 (this, v);
  printf ("=== in A::method2, a_value = %d \n",a_value);

}

A::A(void)
{
  a_value = 1010;
  printf ("in A::A, a_value = %d \n",a_value);
}

//ex7.C end
// ex7.h start

class Origin {
 public:
  int o_value;
};

class A : public Origin {
 public:
  void method1 (void);
  virtual void method2 (int v);
  A();
  int a_value;
};

// ex7.h end
-- simple_cpp_interface.adb start
with Ada.Text_Io; use Ada.Text_Io;
package body Simple_Cpp_Interface is

procedure Ada_Method2 (This : in out A; V : Integer) is
   begin
  Ada.Text_Io.Put_Line ("in Ada_Method2, O_Value =" & Integer'Image
(This.O_Value));
  Ada.Text_Io.Put_Line ("in Ada_Method2, A_Value =" & Integer'Image
(This.A_Value));
  Method1 (This);
  Ada.Text_Io.Put_Line ("in Ada_Method2, O_Value =" & Integer'Image
(This.O_Value));
  Ada.Text_Io.Put_Line ("in Ada_Method2, A_Value =" & Integer'Image
(This.A_Value));
  This.A_Value := V;
  Ada.Text_Io.Put_Line ("in Ada_Method2, O_Value =" & Integer'Image
(This.O_Value));
  Ada.Text_Io.Put_Line ("in Ada_Method2, A_Value =" & Integer'Image
(This.A_Value));
   end Ada_Method2;

end Simple_Cpp_Interface;

-- simple_cpp_interface.adb end
-- simple_cpp_interface.ads start

package Simple_Cpp_Interface is
   type A is limited
  record
 O_Value : Integer;
 A_Value : Integer;
  end record;

pragma Convention (CPP, A);

procedure Method1 (This : in out A);
pragma Import (C, Method1);

procedure Ada_Method2 (This : in out A; V : Integer);
pragma Export (C, Ada_Method2);

end Simple_Cpp_Interface;

-- simple_cpp_interface.ads end

-- 
   Summary: [Ada] - C++ interoperability sample program fails,
3.4.2, Linux 2.4.20-8, Red Hat 9.0
   Product: gcc
   Version: 3.4.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: karl at grebyn dot com
CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18085


[Bug ada/18085] [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 2.4.20-8, Red Hat 9.0

2004-10-22 Thread karl at grebyn dot com

--- Additional Comments From karl at grebyn dot com  2004-10-22 12:21 ---
Confirmed still present in current snapshot for gcc 4.0

Reading specs from /home/karl/gnat/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/gcc-4.0-20041017/./configure --prefix=/home/karl/gnat
--enable-languages=c,c++,ada
Thread model: posix
gcc version 4.0.0 20041017 (experimental)


-- 
   What|Removed |Added

Version|3.4.2   |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18085


[Bug ada/18085] [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 2.4.20-8, Red Hat 9.0

2004-10-24 Thread karl at grebyn dot com

--- Additional Comments From karl at grebyn dot com  2004-10-24 22:39 ---
Problem is that the documentation has an incorrect specification of the interface.

By changing ex7.h to the following, the program works.
 
 //ex7.h
 
 class Origin {
  public:
   int a_value;
 };
 class A : public Origin {
  public:
   void method1 (void);
   virtual void method2 (int v);
   A();
   //   int   a_value;
 };

I leave it to the language lawyers to determine why some sort of error wasn't
raised before...

-- 
   What|Removed |Added

   Severity|normal  |minor


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18085


[Bug ada/18085] [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 2.4.20-8, Red Hat 9.0

2004-11-25 Thread karl at grebyn dot com

--- Additional Comments From karl at grebyn dot com  2004-11-25 14:28 
---
Subject: Re:  [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 
2.4.20-8, Red Hat 9.0

I thought I updated that it appears to be a documentation issue...

-- Karl --


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18085


[Bug ada/18085] [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 2.4.20-8, Red Hat 9.0

2004-11-25 Thread karl at grebyn dot com

--- Additional Comments From karl at grebyn dot com  2004-11-25 14:59 
---
Subject: Re:  [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 
2.4.20-8, Red Hat 9.0

I will download the latest 4.0 snapshot and take another look.

-- Karl --


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18085


[Bug ada/18085] [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 2.4.20-8, Red Hat 9.0

2004-11-25 Thread karl at grebyn dot com

--- Additional Comments From karl at grebyn dot com  2004-11-25 15:10 
---
Subject: Re:  [Ada] - C++ interoperability sample program fails, 3.4.2, Linux 
2.4.20-8, Red Hat 9.0

The latest 4.0 snapshot won't build thanks to a breakage in the Ada.  But
the example in the documentation works correctly now.  Maybe I goofed up the
o_ and the a_ by manually copying.  I saved straight from the html page and
it did indeed work (with gcc 3.4.3).

-- Karl --


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18085