From: Tim Prince <timothyprince@sbcglobal.net>
To: Michael P Friedlander <mpf@cs.ubc.ca>
Cc: Andrew Haley <aph@redhat.com>, gcc-help@gcc.gnu.org
Subject: Re: Flags -g and -O give very different results
Date: Sun, 02 Jul 2006 19:41:00 -0000 [thread overview]
Message-ID: <44A82179.6070602@sbcglobal.net> (raw)
In-Reply-To: <877E6F4D-F10A-4AE4-BDF4-629DF1C3DB32@cs.ubc.ca>
Michael P Friedlander wrote:
> Thanks for pointing out various options, Andrew.
>
>>> The behavior of a numerical code I'm working on varies
>>> drastically depending on whether I've compiled it with
>>> the -g or -O flags.
>>>
>>> The code's behavior under -g is much more stable, and I'm
>>> wondering if the -O flag is exposing a bug that I need to
>>> fix. Are there some gcc flags that I should try that might
>>> guide me in finding the problem? (I've already tried the
>>> obvious -Wall which gives no warnings.)
>>
>> If your code does something different with/without -g, then that's a
>> bug in gcc. -g shouldn't make any difference to the behaviour of your
>> program.
>
> -g makes no difference.
>
>> If your code does somethig different with -O, that's possibly a gcc
>> bug but it's probably a bug in your code.
>
> -OO and -O give different results.
>
>> If you use -fno-strict-aliasing and that makes a difference with -O,
>> then that's definitely a bug in your code.
>
> I think you nailed it! With -fno-strict-aliasing, -O0 and -O give
> identical results. I tried -fstrict-aliasing with -Wstrict-aliasing=2,
> but gcc doesn't issue any warnings.
>
> Any pointers for how to track this sort of thing down? What kind of
> things should I look for?
>
-fstrict-aliasing asserts that your code complies with the C standard on
typed aliasing. Pointers to objects of incompatible type must not
modify the same storage locations. Code which violated this restriction
was common, prior to the time when gcc introduced this option.
next prev parent reply other threads:[~2006-07-02 19:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-01 2:35 Michael P Friedlander
2006-07-02 18:31 ` Andrew Haley
2006-07-02 19:28 ` Michael P Friedlander
2006-07-02 19:41 ` Tim Prince [this message]
2006-07-02 21:00 ` Segher Boessenkool
2006-07-02 21:05 ` Brian Dessent
2006-07-03 9:32 ` Andrew Haley
2006-07-03 10:40 ` Brian Gough
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=44A82179.6070602@sbcglobal.net \
--to=timothyprince@sbcglobal.net \
--cc=aph@redhat.com \
--cc=gcc-help@gcc.gnu.org \
--cc=mpf@cs.ubc.ca \
--cc=tprince@myrealbox.com \
/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).