This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ada miscompilation on mainline


On Sat, 2003-05-10 at 01:35, Zack Weinberg wrote:
> Laurent GUERBY <guerby@acm.org> writes:
> > Hi Zack, it looks like the problem I reported
> > in <http://gcc.gnu.org/ml/gcc/2003-05/msg00609.html> 
> > started to appear with the following patch:
> I am not fluent in Ada.  Could you please attempt to reduce the test
> case further?  In particular it would be nice if you could reproduce
> the problem with a single unit with no 'with' statements, ideally <100
> lines; then I have a chance of tracing what's going on.

I was able to reduce it to a few lines, but not to one unit, may be
this is because of inlining (but you need to compile
only one unit to see the problem by looking at the assembly generated). 

Note that the "with Ada.Exceptions" is useless but without it
the bug doesn't occur.

Laurent

$ cat q.ads
with Ada.Exceptions;
package Q is

   type Ptr is access Character;
   type Entry_Call_Record is record
      Self  : Ptr;
   end record;

   type Entry_Call_Array is array (1 .. 2) of Entry_Call_Record;

   type Common_ATCB is record
      State : Integer;
   end record;

   type Ada_Task_Control_Block (Entry_Num : Integer) is record
      Common : Common_ATCB;
      Entry_Calls : Entry_Call_Array;
   end record;
end Q;

$ cat p.adb
with Q; use Q;
procedure P is
   XX : Ada_Task_Control_Block (1);
begin
   null;
end P;

$ gnatmake -O1 -f -gnatpn p
gcc -c -O1 -gnatpn p.adb
gcc -c -O1 -gnatpn q.ads
gnatbind -x p.ali
gnatlink p.ali
./p.o(.text+0x1a): In function `_ada_p':
: undefined reference to `.LC0'
collect2: ld returned 1 exit status
gnatmake: *** link failed.
$ gcc -S -O1 -gnatpn p.adb
$ cat p.s
	.file	"p.adb"
	.text
.globl _ada_p
	.type	_ada_p, @function
_ada_p:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$40, %esp
	movl	%ebx, -12(%ebp)
	movl	%esi, -8(%ebp)
	movl	%edi, -4(%ebp)
	movl	$1, -40(%ebp)
	leal	-32(%ebp), %eax
	movl	$.LC0, %edx
	movl	%eax, %ebx
	movl	%edx, %esi
	movl	(%edx), %edx
	movl	4(%esi), %edi
	cmpl	%edi, %edx
	jg	.L26
	movl	%edx, %ecx
.L32:
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	$0, (%ebx,%eax,4)
	cmpl	%edi, %ecx
	je	.L26
	incl	%ecx
	jmp	.L32
.L26:
	movl	-12(%ebp), %ebx
	movl	-8(%ebp), %esi
	movl	-4(%ebp), %edi
	movl	%ebp, %esp
	popl	%ebp
	ret
	.size	_ada_p, .-_ada_p
	.ident	"GCC: (GNU) 3.4 20030507 (experimental)"



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]