This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
optimization problem (with -O9)
- From: aditya <aditya dot ps at ap dot sony dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 13 Feb 2002 21:42:50 +0530
- Subject: optimization problem (with -O9)
hello,
I don't know whether this is right place to ask this question ?
I am compiling my code with optimization level O9 for mips r5000.
i am using gcc version 2.9-gnupro-99r1.
The same Code is working fine with optimization level O0.
but with O9 this program is not working. (Program is given below)
and if i complete the if {} else {} then this is working with O9.
is there any problem associated with O9 optimization level.?
any additional information of O9 will be useful for me.
Thanks
Aditya
int fd = 0;
void err_check(int r)
{
int i;
if(r==0)
{
printf("fflush success \r\n");
}
else
{
printf("fflush:failed\r\n");
}
}
main()
{
int ret = 0;
FILE *fp1 = NULL, *fp2 = NULL;
char *str1 = "Hello World";
char *str2 = "Hello world2";
fp1 = fopen("fflush_int.cc","w");
if(fp1 == NULL)
{
printf("fopen failed\r\n");
}
ret = fwrite(str1,(size_t)1,(size_t)11,fp1);
if( ret > 0)
printf("fwrite success\r\n");
else
printf("fwrite failed\r\n");
ret = fflush(fp1);
err_check(ret);
if (fp1 != NULL)
{
fclose(fp1);
printf("in test after fclose\r\n");
}
#if 0 //here if i make this #if 1 the program is working fine(with O9) else segmentation fault.
else
printf("after 1st if block\n");
#endif
printf("after 1st if block\n");
}