[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in Gcc 2.5.8



Hello!

There has been this problem with mint kernels compiled with gcc 2.5.8 and
the multitos aes. Now I have found a compiler bug, which might be
responsible for that:

Here is the example code:

extern void * malloc(long size);
extern void free(void *p);

char *
foo()
{
	char *p;
	void *pt;

	pt = malloc(100);
	if (!pt) return 0;

	p = (char*)malloc(200);
	if (!p) {
		free(pt);
		return 0;
	}
	return p;
}

which leads, when compiled with -O2 -fomit-frame-pointer -mshort to

#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
	.even
.globl _foo
_foo:
	movel a2,sp@-
	movel d2,sp@-
	pea 100:w
	lea _malloc,a2
	jbsr a2@
	movel d0,d2
	addqw #4,sp     | here the Zero flag get overwritten!
	jne L2
	moveq #0,d0
	jra L1
L2:
	pea 200:w
	jbsr a2@
	addqw #4,sp
	tstl d0
	jne L3
	movel d2,sp@-
	jbsr _free
	moveq #0,d0
	addqw #4,sp
L3:
L1:
	movel sp@+,d2
	movel sp@+,a2
	rts

So, as it seems, gcc get caught by its delayed stack cleanup...
Is Bammi still on this list? Well, I will also send this report to
the gnu bug list...

Regards,
Ulrich

--
+---------------+----------------------------+-----------------------+
| Ulrich Kuehn  | Internet:                  | Life is uncertain --  |
| Cand.Math.Inf | kuehn@math.uni-muenster.de | eat the dessert first |
+---------------+----------------------------+-----------------------+