From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040309 Description of problem: when checking a const pointer, a NULL can be treated as "true" when -Os optimization is used. As in the testcase I'll attach: const char *tray_name=NULL; ... if (tray_name) { // this branch is executed } else { // this branch should be executed } Version-Release number of selected component (if applicable): 3.3.3-2.1 How reproducible: Always Steps to Reproduce: 1. grab to-be-attached testcase 2. gcc -o test -Os test.c 3. ./test Actual Results: "oops" Expected Results: "yay" Additional info: this bug also occurs in FC1 gcc (3.2.2-1) and resulted in the Mozilla bug here: http://bugzilla.mozilla.org/show_bug.cgi?id=233497 Adding -fno-gcse fixes the testcase. I tried out gcc34-3.4.0-0.6, and it handles the testcase properly.
Created attachment 98452 [details] testcase C program output is "oops", but should be "yay".
This seems to be the same issue as http://gcc.gnu.org/bugzilla/PR12308. I've backported the patch to gcc-3_3-rhl-branch and gcc-3_4-branch and will include them in the next set of rpms. Thanks.
Make that http://gcc.gnu.org/PR12308