From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31174 invoked by alias); 4 Jul 2002 20:06:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31140 invoked by uid 71); 4 Jul 2002 20:06:01 -0000 Resent-Date: 4 Jul 2002 20:06:01 -0000 Resent-Message-ID: <20020704200601.31139.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jdbuiso@cs.vu.nl Received: (qmail 29046 invoked by uid 61); 4 Jul 2002 19:58:31 -0000 Message-Id: <20020704195831.29045.qmail@sources.redhat.com> Date: Thu, 04 Jul 2002 13:06:00 -0000 From: jdbuiso@cs.vu.nl Reply-To: jdbuiso@cs.vu.nl To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7209: Faulty array dereferencing X-SW-Source: 2002-07/txt/msg00179.txt.bz2 List-Id: >Number: 7209 >Category: c++ >Synopsis: Faulty array dereferencing >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu Jul 04 13:06:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jornand de Buisonjé >Release: 3.1 >Organization: >Environment: DOS (DJGPP) and Linux, both x86. >Description: Dereferencing an array using a ternary operation (?:) and a function return value as indices can give faulty (and variable) results. In the example code one or more of the asserts can fail (depending on the optimization level), but only when compiling as C++. >How-To-Repeat: >Fix: Doing the ternary operation and/or function call before the array indexing solves (avoids) the problem. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="Bug.cpp" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Bug.cpp" I2luY2x1ZGUgPGFzc2VydC5oPg0KDQp1bnNpZ25lZCBjaGFyIGFbMl1bMV1bMTZdPXsNCiAge3sw eDAwLDB4MDAsMHgwMCwweDAwLDB4MDAsMHgwMCwweDAwLDB4MDAsMHgwMCwweDAwLDB4MDAsMHgw MCwweDAwLDB4MDAsMHgwMCwweDAwfX0sDQogIHt7MHgwMCwweDAwLDB4MDAsMHgwMCwweDAwLDB4 MDAsMHgwMCwweDAwLDB4MDAsMHgwMCwweDAwLDB4MDAsMHgwMCwweDAwLDB4MDAsMHgwMH19fTsN Cg0KaW50IGYoKQ0Kew0KICByZXR1cm4gMDsNCn0NCg0KaW50IG1haW4oKQ0Kew0KICBpbnQgZD0w Ow0KICB1bnNpZ25lZCBjaGFyKiBjMSwqIGMyOw0KICBjMT1hW2Q9PTAgPyAwIDogMV1bZigpXTsN CiAgYzI9YVtkPT0wID8gMCA6IDFdW2YoKV07DQogIGFzc2VydCgoaW50KWE9PShpbnQpYzEpOw0K ICBhc3NlcnQoYzE9PWMyKTsNCiAgcmV0dXJuIDA7DQp9DQo=