This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/493: gcc creates incorrect code generated with x ? L"X":L"Y"



>Number:         493
>Category:       c
>Synopsis:       gcc creates incorrect code generated with x ? L"X":L"Y"
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 29 11:16:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     chris.gilbert@citrix.com
>Release:        gcc 2.95.2 powerpc and gcc 2.8.1 sparc
>Organization:
>Environment:
aix 4.3.3.0 (powerpc-ibm-aix4.3.3.0)
Solaris 2.6
>Description:
When compiling the attached c code it incorrectly outputs:
X
X
instead of:
Y
X
It seems that the compiler is assuming that the value==1 is always true.
Note that this doesn't happen on gcc 2.8.1 ix86 on solaris 2.7
>How-To-Repeat:
compile code:
$gcc gccifbug.c
$./a.out
X
X
>Fix:
Workaround: replace the ? : block with a proper if {}else {}
 
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gccifbug.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gccifbug.c"

I2luY2x1ZGUgPHdjaGFyLmg+CiNpbmNsdWRlIDxzdGRpby5oPgoKY29uc3Qgd2NoYXJfdCAqIHRl
c3RmdW5jKGludCB2YWx1ZSkgewogICAgcmV0dXJuICgodmFsdWU9PTEpID8gTCJYIjpMIlkiKTsK
fQoKaW50IG1haW4odm9pZCkgewogICAgCiAgICBwcmludGYoIiVTXG4iLCB0ZXN0ZnVuYygwKSk7
CiAgICBwcmludGYoIiVTXG4iLCB0ZXN0ZnVuYygxKSk7CgogICAgcmV0dXJuIDA7Cn0KICAgIAo=

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]