Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug in gcc -O2



Hi guys... today I got feedback from apple people. the solution they have given is

When compiling with -O2, add the flag "-fno-branch-count-reg".
This will force the code to compile correctly.

Just in case someone is interested.
Spundun


Spundun Bhatt wrote:

hi, I hope this is the right mailing list to post this message

I have found a bug with gcc which is like this.
gcc generates wrong code when -O2 is used
(describing it in terms of shell out put)
note: I have tried to make the code as smmall as possible while still being aboel to reproduce the bug. So some parts of code will look useless.
--------------------------------------------------------------------------------------------------------

Spundun-Bhatts-Computer:~ spundunbhatt$ cat test.c
int printf(const char * , ...);
int foo(const char *a , ...){};
static char * xpm = " ... ";
char mask_buffer=0;
int main() {
int height, width, colors, x, pix;
foo (xpm ,&height, &width, &colors, &pix);
for (x = 0; x < 8;){
for (pix = 0; pix < 8; pix++, x++){
if (xpm [x] != ' '){
mask_buffer |= 1 << pix;
}
}
}
printf("mask is %d\n",mask_buffer);
}
Spundun-Bhatts-Computer:~ spundunbhatt$ gcc -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1495)
Spundun-Bhatts-Computer:~ spundunbhatt$ gcc test.c -O1
Spundun-Bhatts-Computer:~ spundunbhatt$ ./a.out
mask is -32
Spundun-Bhatts-Computer:~ spundunbhatt$ gcc test.c -O2
Spundun-Bhatts-Computer:~ spundunbhatt$ ./a.out
mask is 7
Spundun-Bhatts-Computer:~ spundunbhatt$ gcc test.c -O3
Spundun-Bhatts-Computer:~ spundunbhatt$ ./a.out
mask is -32
Spundun-Bhatts-Computer:~ spundunbhatt$ gcc test.c -Os
Spundun-Bhatts-Computer:~ spundunbhatt$ ./a.out
mask is -32
Spundun-Bhatts-Computer:~ spundunbhatt$

--------------------------------------------------------------------------------------------------------


Thanx
Spundun
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



--
If popularity breeds vulnerability, Apache should have far more vulnerabilities than IIS. It doesn't.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.