public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: me@andydunn.ca To: gcc-gnats@gcc.gnu.org Subject: c/6192: gcc array reference incorrect on multi-dimensional array Date: Fri, 05 Apr 2002 12:06:00 -0000 [thread overview] Message-ID: <20020405195759.22545.qmail@sources.redhat.com> (raw) >Number: 6192 >Category: c >Synopsis: gcc array reference incorrect on multi-dimensional array >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Apr 05 12:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Andrew Michael Dunn >Release: gcc-2.96, also others older >Organization: >Environment: RedHat 7.0 2.2.16-22 kernel, also others (eg. Caldera 2.2.5) >Description: When accessing a two-dimensional array of ints, writing to any row (first dimension) of the array then reading from any row returns the value written (see example provided). Accessing the array memory space as a linear single-dimension array of ints proves that only the first row gets written, regardless of the array index, and only the first row gets read. ie. int array[3,2] assignment array[1,0] = 3 the 3 actually gets written into array[0,0] inspecting array[0,0], array[1,0] or array[2,0] all of these return the value 3 (which was written only into array[0,0] originally Single-dimension int arrays do not have this problem >How-To-Repeat: See attached xtest.c - very reproducible on multiple machines, kernel revs, gcc versions, etc. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="xtest.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="xtest.c" I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgYXJyYXlbMywyXTsKCnZvaWQgb3V0cHV0X3NlcXVlbnRp YWwoYXJyYXkpCmludCBhcnJheVs2XTsKewoJcHJpbnRmKCJhcnJheVswXSA9ICVkICAgYXJyYXlb MV0gPSAlZCAgICAgIGFycmF5WzJdID0gJWRcbiIsYXJyYXlbMF0sCgkJCWFycmF5WzFdLGFycmF5 WzJdKTsKCXByaW50ZigiYXJyYXlbM10gPSAlZCAgIGFycmF5WzRdID0gJWQgICAgICBhcnJheVs1 XSA9ICVkXG4iLGFycmF5WzNdLAoJCQlhcnJheVs0XSxhcnJheVs1XSk7Cn0KCm1haW4oKQp7Cglp bnQgemVybzsKCglhcnJheVswLDBdID0gMDsKCWFycmF5WzAsMV0gPSAwOwoJYXJyYXlbMSwwXSA9 IDA7CglhcnJheVsxLDFdID0gMDsKCWFycmF5WzIsMF0gPSAwOwoJYXJyYXlbMiwxXSA9IDA7CgoJ cHJpbnRmKCJUV08gRElNRU5TSU9OIEFSUkFZLi4uXG5cbiIpOwoJcHJpbnRmKCJCRUZPUkU6IGFy cmF5WzAsMF0gPSAlZCAgYXJyYXlbMSwwXSA9ICVkIGFycmF5WzIsMF0gPSAlZFxuIiwKCQlhcnJh eVswLDBdLGFycmF5WzEsMF0sYXJyYXlbMiwwXSk7CglwcmludGYoIiAgICAgICAgYXJyYXlbMCwx XSA9ICVkICBhcnJheVsxLDFdID0gJWQgYXJyYXlbMiwxXSA9ICVkXG4iLAoJCWFycmF5WzAsMV0s YXJyYXlbMSwxXSxhcnJheVsyLDFdKTsKCglwcmludGYoIlxuZXhlY3V0aW5nIEFSUkFZWzEsMF0g PSAzXG4iKTsKCWFycmF5WzEsMF0gPSAzOwoKCXByaW50ZigiXG5leGVjdXRpbmcgQVJSQVlbMiwx XSA9IDVcbiIpOwoJYXJyYXlbMiwxXSA9IDU7CgoJcHJpbnRmKCJcbkFGVEVSOiBhcnJheVswLDBd ID0gJWQgIGFycmF5WzEsMF0gPSAlZCBhcnJheVsyLDBdID0gJWRcbiIsCgkJYXJyYXlbMCwwXSxh cnJheVsxLDBdLGFycmF5WzIsMF0pOwoJcHJpbnRmKCIgICAgICAgYXJyYXlbMCwxXSA9ICVkICBh cnJheVsxLDFdID0gJWQgYXJyYXlbMiwxXSA9ICVkXG4iLAoJCWFycmF5WzAsMV0sYXJyYXlbMSwx XSxhcnJheVsyLDFdKTsKCglvdXRwdXRfc2VxdWVudGlhbChhcnJheSk7Cn0K
next reply other threads:[~2002-04-05 20:06 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-05 12:06 me [this message] 2002-04-05 12:20 hp 2002-04-05 13:06 Andrew M Dunn
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020405195759.22545.qmail@sources.redhat.com \ --to=me@andydunn.ca \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).