Bug 57676 - Incorrect Code with multi-dimensional strings and inheritance
Incorrect Code with multi-dimensional strings and inheritance
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.2
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
http://gidayu.mud.de/~chris/testcase.cc
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-12-18 15:05 EST by Christian Loth
Modified: 2007-04-18 12:38 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-01 21:07:28 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Testcase C++ Source (898 bytes, text/plain)
2001-12-19 12:25 EST, Christian Loth
no flags Details

  None (edit)
Description Christian Loth 2001-12-18 15:05:56 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5+) Gecko/20011012

Description of problem:
Addressing a static const multi-dimensional array in an inherited
class results in wrong code generation for the C++ frontend of gcc.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Compile program testcase.cc from above URL with parameters -O2 -Wall -g
2.Run the binary: ./testcase
3.
	

Actual Results:  Output:
00
01
02
10
11
12
20
21
22
 
AA
AA
AA
BA
BA
BA
CA
CA
CA

Expected Results:  Output:
00
01
02
10
11
12
20
21
22
 
AA
AB
AC
BA
BB
BC
CA
CB
CC

Additional info:

Happens with the following compiler:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)

Workaround:
Single-dimensional string array with computation
of correct index. E.g.
string strs[] = {
"AA","AB","AC","BA","BB","BC","CA","CB","CC"
};
Access now instead of strs[1][2] use:
strs[1 * 3 + 2]
Comment 1 Christian Loth 2001-12-19 12:25:15 EST
Created attachment 41048 [details]
Testcase C++ Source
Comment 2 Richard Henderson 2004-10-01 21:07:28 EDT
Works with gcc 3.2.

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