ee-gcc (PSX2 GCC) compiler bug (fwd)
Denis Fabrice
dfabrice@frd.co.uk
Tue Feb 1 08:44:00 GMT 2000
Hello,
I would like to report a bug concerning the playstation2 development kit
port of DJGPP.
I am a new programmer so I haven't much details about the products but
basically I was said you have developed the compiler for Sony's
playstation2 devkit.
The compiler we use is named 'ee-gcc'.
I came upon a situation where a pointer is not increased as it should be.
Here is a piece of code that works:
int pts[4*3];
int *ppts = pts;
*ppts++ = RGBA2COL(100,0,0,127); //just some macro..
*ppts++ = windowLeft()+50; // some other macros..
*ppts++ = windowTop()+20;
// here the ppts pointer is correctly increased by 12 bytes
I changed the code then to use some math functions,
the following code does _not_ work:
int pts[4*3];
int *ppts = pts;
int rgba;
< .... >
printf("Argh %x %x\n", pts, ppts);
*ppts++ = rgba;
*ppts++ = cosf( DEG2RAD(ang2) ) * xradi1;
*ppts++ = sinf( DEG2RAD(ang2) ) * yradi1;
printf("Argh %x %x\n", pts, ppts);
The output revealed that ppts is increased by _4_, not by 12.
(so it increases correctly for the line with 'rgba', but not on the
lines with the math functions)
However, if I change the code so that ppts is increased on a separate
line, it works:
*ppts++ = rgba;
*ppts = cosf( DEG2RAD(ang2) ) * xradi1;
ppts++;
*ppts = sinf( DEG2RAD(ang2) ) * yradi1;
ppts++;
So, it looks like the pointer arithmetic gets faulty when cosf / sinf is
used.
This is the code I am currently using to fix the problem.
This is the declaration of the macro:
#define DEG2RAD(a) ((a)*PI/180.0f)
This is the declaration of the math functions in math.h:
( /usr/local/sce/ee/gcc/ee/include/math.h )
extern float cosf _PARAMS((float));
extern float sinf _PARAMS((float));
The following code does work:
*ppts++ = rgba;
*ppts++ = 4.0f; //cosf(DEG2RAD(ang1))*xradi1;
*ppts++ = 4.0f; //sinf(DEG2RAD(ang1))*yradi1;
... as I was testing another variation, the compiler got an internal
error with this code:
*ppts++ = rgba;
*ppts++ = cosf(1.1f);
*ppts++ = sinf(1.2f);
Here is the output:
-------------------------------------------------------------------------------
red> make
-- tool1/tool1.c --
tool1/tool1.c: In function `move_prop':
tool1/tool1.c:197: warning: unused variable `vel'
tool1/tool1.c: In function `drawsection':
tool1/tool1.c:630: warning: unsigned int format, pointer arg (arg 2)
tool1/tool1.c:630: warning: unsigned int format, pointer arg (arg 3)
../../src/gcc/emit-rtl.c:2486: Internal compiler error in function
add_insn_before
Please submit a Problem Report to Cygnus Solutions with send-pr.
make: *** [tool1/tool1.o] Error 1
red>
-------------------------------------------------------------------------------
I have no idea is this might be useful to you:
red> ee-gcc -print-libgcc-file-name
/usr/local/sce/ee/gcc/lib/gcc-lib/ee/2.9-ee-990721/libgcc.a
To be honest the send-pr program looks like a lot of trouble, I
hope you have enough information here. However, if you need any
additional detail I will be pleased to help you.
Regards,
Denis Fabrice
dfabrice@frd.co.uk
More information about the Gcc-bugs
mailing list