public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@physics.uc.edu>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: optimization/6985: GCC-3.x incorrectly initializes local arrays
Date: Mon, 10 Jun 2002 20:26:00 -0000	[thread overview]
Message-ID: <20020611032602.22467.qmail@sources.redhat.com> (raw)

The following reply was made to PR optimization/6985; it has been noted by GNATS.

From: Andrew Pinski <pinskia@physics.uc.edu>
To: lucho@haemimont.bg
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/6985: GCC-3.x incorrectly initializes local arrays
Date: Mon, 10 Jun 2002 21:22:47 -0400

 This is not a bug but your code violates ISO C's aliasing rules 
 (C89, ANSI C).
 To work around this use an union or use the option 
 `-fno-strict-aliasing'.
 Thanks,
 Andrew Pinski
 
 On Monday, June 10, 2002, at 08:48 , lucho@haemimont.bg wrote:
 
 > /*
 >  * GCC-3.1 bug
 >  * compile with -O2 to let the bug to appear.
 >  *
 >  * The test should output (and does so when compiled with -O1 or less):
 >  *
 >  * aaaaa
 >  * a=13
 >  *
 >  * but when compiled with -O2 or higher, instead it outputs:
 >  *
 >  * aaaaa
 >  * a=0
 >  *
 >  *
 >  * I've tested this on 2.95.2, 3.0, 3.0.4 and 3.1.
 >  * 2.95.2 doesn't have this bug and all 3.x have it.
 >  */
 >
 > unsigned a = 13, b = 17;
 >
 > int main()
 > {
 > 	unsigned char buf[18] = {0};
 > 	*(unsigned short *)(buf + 12) = a;
 > 	*(unsigned short *)(buf + 14) = b;
 > 	printf("aaaaa\n");
 > 	printf("a=%i\n", *(unsigned short *)(buf + 12));
 > 	return 0;
 > }
 


             reply	other threads:[~2002-06-11  3:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-10 20:26 Andrew Pinski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-06-10 17:56 lucho

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=20020611032602.22467.qmail@sources.redhat.com \
    --to=pinskia@physics.uc.edu \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@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).