Bug 118026 - const pointer NULL treated as "true" expression with -Os
Summary: const pointer NULL treated as "true" expression with -Os
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc   
(Show other bugs)
Version: rawhide
Hardware: athlon Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL: http://bugzilla.mozilla.org/show_bug....
Depends On:
TreeView+ depends on / blocked
Reported: 2004-03-11 08:38 UTC by Andrew Schultz
Modified: 2007-11-30 22:10 UTC (History)
1 user (show)

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

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

Description Andrew Schultz 2004-03-11 08:38:22 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b)

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):

How reproducible:

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:

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 08:41:22 UTC
Created attachment 98452 [details]
testcase C program

output is "oops", but should be "yay".

Comment 2 Jakub Jelinek 2004-03-11 15:50:27 UTC
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 15:51:13 UTC
Make that http://gcc.gnu.org/PR12308

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