Bug 57676 - Incorrect Code with multi-dimensional strings and inheritance
Summary: Incorrect Code with multi-dimensional strings and inheritance
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.2
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL: http://gidayu.mud.de/~chris/testcase.cc
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-12-18 20:05 UTC by Christian Loth
Modified: 2007-04-18 16:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-02 01:07:28 UTC
Embargoed:


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

Description Christian Loth 2001-12-18 20:05:56 UTC
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 17:25:15 UTC
Created attachment 41048 [details]
Testcase C++ Source

Comment 2 Richard Henderson 2004-10-02 01:07:28 UTC
Works with gcc 3.2.


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