public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: David Mosberger <davidm@hpl.hp.com>
To: gcc-gnats@gcc.gnu.org
Cc: davidm@hpl.hp.com
Subject: c/5420: bad code generated with gcc3.1/ia64
Date: Thu, 17 Jan 2002 18:56:00 -0000	[thread overview]
Message-ID: <200201180252.g0I2qOh29734@wailua.hpl.hp.com> (raw)


>Number:         5420
>Category:       c
>Synopsis:       bad code generated with gcc3.1/ia64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 17 18:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     David Mosberger
>Release:        3.1 20020117 (experimental)
>Organization:
HP Labs
>Environment:
System: Linux wailua.hpl.hp.com 2.4.17 #2 SMP Thu Jan 17 13:53:26 PST 2002 ia64 unknown
Architecture: ia64

	ia64, Linux, ia64
host: ia64-hp-linux-gnu
build: ia64-hp-linux-gnu
target: ia64-hp-linux-gnu
configured with: ../gcc/configure --prefix=/opt/gcc3.1 --host=ia64-hp-linux : (reconfigured) 
>Description:
	On the attached test program, gcc generates bad code with
	an optimization level of -O2.  -O works fine.
>How-To-Repeat:
	$ gcc -O2 test.c
	$ ./a.out
	./a.out 
	dev=1220
	dev=1220

This is wrong.  The correct output should be:

	dev=800
	dev=810

>Fix:
	The workaround is to drop the optimization level to -O.

<-- test.c --><-- test.c --><-- test.c --><-- test.c -->
typedef struct {
	unsigned short value;
} kdev_t;

#define mk_kdev(major, minor)	((kdev_t) { (((major) << 8) + (minor)) } )

#define SD_MAJOR(i)		(!(i) ? 8 : 65-1+(i))
#define MKDEV_SD_PARTITION(i)	mk_kdev(SD_MAJOR((i) >> 8), (i))

int
main (int argc, char **argv)
{
	int idx;

	for (idx = 0; idx < 2; ++idx)
		printf ("dev=%x\n", MKDEV_SD_PARTITION((idx) << 4).value);
}
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-01-18  2:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-17 18:56 David Mosberger [this message]
2002-02-06  5:25 jakub
2002-02-22 20:38 rodrigc

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=200201180252.g0I2qOh29734@wailua.hpl.hp.com \
    --to=davidm@hpl.hp.com \
    --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: 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).