This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 118026 - const pointer NULL treated as "true" expression with -Os
const pointer NULL treated as "true" expression with -Os
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
athlon Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
http://bugzilla.mozilla.org/show_bug....
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-11 03:38 EST by Andrew Schultz
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version: 3.3.3-3
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-17 07:52:42 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
testcase C program (720 bytes, text/plain)
2004-03-11 03:41 EST, Andrew Schultz
no flags Details

  None (edit)
Description Andrew Schultz 2004-03-11 03:38:22 EST
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.
Comment 1 Andrew Schultz 2004-03-11 03:41:22 EST
Created attachment 98452 [details]
testcase C program

output is "oops", but should be "yay".
Comment 2 Jakub Jelinek 2004-03-11 10:50:27 EST
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.
Comment 3 Jakub Jelinek 2004-03-11 10:51:13 EST
Make that http://gcc.gnu.org/PR12308

Note You need to log in before you can comment on or make changes to this bug.