public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dkegel at ixiacom dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug optimization/10392] [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
Date: Sat, 13 Sep 2003 00:13:00 -0000	[thread overview]
Message-ID: <20030912230854.4532.qmail@sources.redhat.com> (raw)
In-Reply-To: <20030413145600.10392.marcus@mc.pp.se>

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10392



------- Additional Comments From dkegel at ixiacom dot com  2003-09-12 23:08 -------
OK, how 'bout this?  This reproduces the crash nicely,
and should be ready to check in as a dg testcase.

/* PR optimization/10392
 * [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
 * The address calculation of an index operation on an array on the stack 
 * can _under some conditions_ get messed up completely
*/
/* { dg-do run } */

const char *foo;

const char *use(const char *str)
{
	foo = str;
	return str[0] ? "apple" : "bannana";
}

const char *func(char *a, char *b)
{
	char buf[128];
	unsigned char i;
	const char *result;

	char *item[] = {
		"one",
		"two",
	};

	buf[0] = 'b';
	buf[1] = 0;

	for (i = 0; i < 2; i++) {
		/* bug is: following line crashes with SIGSEGV on sh4 -O2 */
		result = use(item[i]);

		use(buf);
		use(a);
		use(b);
		result = use(result);
	}
	return result;
}

int main()
{
	/* func never returns zero, so this will always exit with status 0,
	 * but the optimizer doesn't know that 
	 */
	return func("a", "b") != 0;
}


  parent reply	other threads:[~2003-09-12 23:08 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030413145600.10392.marcus@mc.pp.se>
2003-06-01 17:57 ` marcus@mc.pp.se
2003-06-08 18:58 ` pinskia@physics.uc.edu
2003-06-28  1:00 ` giovannibajo at libero dot it
2003-07-11 22:55 ` mmitchel at gcc dot gnu dot org
2003-09-07 14:28 ` ebotcazou at gcc dot gnu dot org
2003-09-12  6:56 ` ebotcazou at gcc dot gnu dot org
2003-09-12  7:42 ` dank at kegel dot com
2003-09-12  8:18 ` ebotcazou at gcc dot gnu dot org
2003-09-12 19:12 ` marcus at mc dot pp dot se
2003-09-12 22:27 ` ebotcazou at gcc dot gnu dot org
2003-09-12 22:27 ` marcus at mc dot pp dot se
2003-09-13  0:13 ` dkegel at ixiacom dot com [this message]
2003-09-13  1:25 ` dkegel at ixiacom dot com
2003-09-13  9:58 ` ebotcazou at gcc dot gnu dot org
2003-09-13 13:53 ` marcus at mc dot pp dot se
2003-09-13 13:58 ` ebotcazou at gcc dot gnu dot org
2003-09-13 17:55 ` dank at kegel dot com
2003-09-13 22:24 ` marcus at mc dot pp dot se
2003-09-15 17:44 ` dank at kegel dot com
2003-09-15 19:34 ` marcus at mc dot pp dot se
2003-09-16  5:11 ` dank at kegel dot com
2003-09-16 13:22 ` marcus at mc dot pp dot se
2003-09-16 18:43 ` dank at kegel dot com
2003-09-17 10:05 ` ebotcazou at gcc dot gnu dot org
2003-09-17 17:49 ` dank at kegel dot com
2003-09-18  5:41 ` ebotcazou at gcc dot gnu dot org
2003-09-18  6:09 ` dank at kegel dot com
2003-10-16  2:58 ` mmitchel at gcc dot gnu dot org
2003-10-16  4:29 ` ebotcazou at gcc dot gnu dot org
2003-10-16  6:40 ` dank at kegel dot com
2003-10-16  6:52 ` ebotcazou at gcc dot gnu dot org
2003-10-25 15:12 ` ebotcazou at gcc dot gnu dot org
2003-12-21 18:53 ` gdr at gcc dot gnu dot org
2004-01-14  8:08 ` gdr at gcc dot gnu dot org
2004-01-14 19:03 ` joern dot rennecke at superh dot com
2004-01-14 19:37 ` joern dot rennecke at superh dot com
2004-01-14 19:49 ` [Bug optimization/10392] [3.3 " pinskia at gcc dot gnu dot org
2004-01-15 20:22 ` cvs-commit at gcc dot gnu dot org
2004-01-16 18:24 ` cvs-commit at gcc dot gnu dot org
2004-01-16 18:28 ` amylaar at gcc dot gnu dot org
2004-01-21 12:46 ` ebotcazou at gcc dot gnu dot org
2004-01-21 12:46 ` ebotcazou at gcc dot gnu dot org
2004-01-21 14:09 ` gdr at integrable-solutions dot net
2004-01-25  7:14 ` ebotcazou at gcc dot gnu dot org

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=20030912230854.4532.qmail@sources.redhat.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).