From: "Harald van Dijk" <truedfx@gentoo.org>
To: gcc-help@gcc.gnu.org
Subject: -fstrict-aliasing, -Wstrict-aliasing=2, and indirect conversions
Date: Tue, 26 Jul 2005 23:52:00 -0000 [thread overview]
Message-ID: <42E6CE1E.3080200@gentoo.org> (raw)
Hello,
int main() {
int a = 1;
short *b = (short *) (char *) &a;
*b = 2;
return a;
}
This simple program returns 1 when compiled with -O2 -fstrict-aliasing,
and 2 when compiled with -O2 -fno-strict-aliasing. It does not produce
any warnings with -Wstrict-aliasing=2. According to the documentation:
`-Wstrict-aliasing=2'
This option is only active when `-fstrict-aliasing' is active. It
warns about all code which might break the strict aliasing rules
that the compiler is using for optimization. This warning catches
all cases, but it will also give a warning for some ambiguous
cases that are safe.
Is this a bug? If so, what is the bug? Is the warning missing, or is the
optimization invalid? And are there any alternative options that really
catch every aliasing problem?
I'm using gcc 4.0.1 on i686-pc-linux-gnu.
Thanks in advance for any replies.
next reply other threads:[~2005-07-26 23:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-26 23:52 Harald van Dijk [this message]
2005-07-27 2:37 ` Ian Lance Taylor
2005-07-27 21:17 ` Harald van Dijk
2005-07-27 22:23 ` Ian Lance Taylor
2005-07-27 23:53 ` Harald van Dijk
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=42E6CE1E.3080200@gentoo.org \
--to=truedfx@gentoo.org \
--cc=gcc-help@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).