From: Alexander Stein Date: Thu, 14 Oct 2010 08:50:29 +0200 Subject: [U-Boot] [PATCH] dlmalloc.c: Fix gcc alias warning In-Reply-To: <1287038480-11338-1-git-send-email-Joakim.Tjernlund@transmode.se> References: <1287038480-11338-1-git-send-email-Joakim.Tjernlund@transmode.se> Message-ID: <201010140850.29272.alexander.stein@systec-electronic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello, On Thursday 14 October 2010, 08:41:20 Joakim Tjernlund wrote: > Fix these warnings: > dlmalloc.c: In function 'free': > dlmalloc.c:2507: warning: dereferencing pointer '({anonymous})' does break > strict-aliasing rules dlmalloc.c:2507: warning: dereferencing pointer > '({anonymous})' does break strict-aliasing rules dlmalloc.c:2507: warning: > dereferencing pointer '({anonymous})' does break strict-aliasing rules > > Some > page(http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing- > problems.html) suggests adding __attribute__((__may_alias__)). Doing so > makes the warnings go away. --- > common/dlmalloc.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/common/dlmalloc.c b/common/dlmalloc.c > index 2276532..c78cacc 100644 > --- a/common/dlmalloc.c > +++ b/common/dlmalloc.c > @@ -1155,7 +1155,7 @@ struct malloc_chunk > INTERNAL_SIZE_T size; /* Size in bytes, including overhead. */ > struct malloc_chunk* fd; /* double links -- used only if free. */ > struct malloc_chunk* bk; > -}; > +} __attribute__((__may_alias__)) ; > > typedef struct malloc_chunk* mchunkptr; > > @@ -1443,7 +1443,7 @@ nextchunk-> > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ > > #define NAV 128 /* number of bins */ > > -typedef struct malloc_chunk* mbinptr; > +typedef struct malloc_chunk* mbinptr __attribute__((__may_alias__)); > > /* access macros */ Though I don't know the actual code why not use a union instead? Regards, Alexander