From: Michal Soltys <soltys@ziu.info>
To: Jes Sorensen <Jes.Sorensen@redhat.com>
Cc: neilb@suse.de, linux-raid@vger.kernel.org, dledford@redhat.com
Subject: Re: [PATCH 1/1] Work around gcc-4.7's strict aliasing checks
Date: Tue, 24 Jan 2012 01:59:38 +0100 [thread overview]
Message-ID: <4F1E027A.40007@ziu.info> (raw)
In-Reply-To: <4F1D57A5.7070104@redhat.com>
On 12-01-23 13:50, Jes Sorensen wrote:
> On 01/22/12 01:49, Michal Soltys wrote:
>> Below is approach to the "problem" from a bit different angle -
>> using alias-permitting type definitions consistently where necessary
>> - so assuring compiler won't (shouldn't ?) pursue any funny ideas no
>> matter what. I'd guess it's the "right" thing to do - aside from
>> going kernel way and using -fno-strict-aliasing everywhere (or
>> #pragmas).
>>
>> The compilation goes cleanly at Wstrict-aliasing=1 - so most
>> aggresive yet most dumb at the same time (note, not checked on 4.7,
>> but obviously I included necessary equivalent changes to the Jes's
>> patch).
>>
>> Anyway - side effects of Wstrict-aliasing=1 are false positives -
>> quite a few of them actually (funcion argument casts where only
>> pointers are involved, some pointers which are not dereferenced
>> "nearby" and/or in the same block) - but false negatives should be
>> (almost ?) nonexistent. As mdadm is rather critical, and itself
>> compiled with Wall, Wextra and Werror - I assume to be extra careful
>> - this should complement those settings well.
>>
>> On a bad side of this approach - it doesn't necessary make the code
>> prettier, and might make people ask "the hell is this ...".
>
> Hi Michal,
>
> Personally I'd rather have someone who knows about the ddf on disk
> format go through the code and fix properly.
> IMHO adding more ugly typedefs is a situation of where the cure is
> worse than the disease.
Btw, the patch went through the whole mdadm, not just ddf part. And
afaik, if we aim to be formally correct - there's no going around
typedefs (which are required for "may_alias" on simple types).
Otherwise, it just tricking gcc into not issuing warnings (even if
the chance of actual problems occuring is absolutely minuscule).
> We're all going through the code trying to come up with workarounds
> for gcc (myself included), rather than fixing the code.
Well, IMHO the [probably] best workaround for now would be
-fno-strict-aliasing then - which avoids warnings, ugly attribute
[over]use, and should assure expected behavior.
Say, near the top of Makefile:
-CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
+CFLAGS = $(CWFLAGS) $(CXFLAGS) -fno-strict-aliasing -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
next prev parent reply other threads:[~2012-01-24 0:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-05 11:16 [PATCH 0/1] gcc-4.7 build fix Jes.Sorensen
2012-01-05 11:16 ` [PATCH 1/1] Work around gcc-4.7's strict aliasing checks Jes.Sorensen
2012-01-11 23:43 ` NeilBrown
2012-01-12 7:14 ` David Brown
2012-01-12 13:45 ` Michal Soltys
2012-01-13 12:20 ` David Brown
2012-01-13 14:21 ` Michal Soltys
2012-01-13 17:48 ` David Brown
2012-01-12 9:24 ` Jes Sorensen
2012-01-22 0:49 ` Michal Soltys
2012-01-22 0:49 ` [PATCH] compile cleanly with -Wstrict-aliasing=1 Michal Soltys
2012-01-23 12:50 ` [PATCH 1/1] Work around gcc-4.7's strict aliasing checks Jes Sorensen
2012-01-24 0:59 ` Michal Soltys [this message]
2012-01-24 9:18 ` David Brown
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=4F1E027A.40007@ziu.info \
--to=soltys@ziu.info \
--cc=Jes.Sorensen@redhat.com \
--cc=dledford@redhat.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.