dlmalloc.c: Fix gcc alias warning
PATCH 1/1 dlmalloc.c: Fix gcc alias warning
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(-)
common/dlmalloc.c +2 -2
@@ -1155,7 +1155,7 @@ struct malloc_chunkINTERNAL_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 */
Signature · 1 line
1.7.2.2
PATCH 1/1 dlmalloc.c: Fix gcc alias warning
Hello,
Quoted 28 lines · 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 rulesSome 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(-)common/dlmalloc.c +1
-1@@ -1155,7 +1155,7 @@ struct malloc_chunkINTERNAL_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 ;
common/dlmalloc.c nextchunk-> · line 1449
Quoted 8 lines
common/dlmalloc.c +2
-1@@ -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
PATCH 1/1 dlmalloc.c: Fix gcc alias warning
Alexander Stein <[email protected]> wrote on 2010/10/14 08:50:29:
Quoted 7 lines
Hello,
Quoted 3 lines · 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
Quoted 2 lines
Quoted 2 lines
strict-aliasing rules dlmalloc.c:2507: warning: dereferencing pointer '({anonymous})' does break strict-aliasing rules dlmalloc.c:2507:
warning:
Quoted 4 lines
Quoted 1 line
dereferencing pointer '({anonymous})' does break strict-aliasing rules
Though I don't know the actual code why not use a union instead?
Me neither, you are welcome to have a crack at it.
Jocke
PATCH v2 1/1 dlmalloc.c: Fix gcc alias warning
In reply to Joakim TjernlundFix 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.
---
- forgot signoff
- removed stray attribute change
common/dlmalloc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
common/dlmalloc.c +1 -1
@@ -1155,7 +1155,7 @@ struct malloc_chunkINTERNAL_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 ;
Signature · 1 line
1.7.2.2
PATCH v2 1/1 dlmalloc.c: Fix gcc alias warning
Quoted 11 lines · On Thursday, October 14, 2010 02:51:34 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 rulesSome 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.
thanks ... i think this is a good stop-gap workaround
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101014/695f94fd/attachment.pgp
Wolfgang Denk
AppliedPATCH v2 1/1 dlmalloc.c: Fix gcc alias warning
In reply to Joakim TjernlundDear Joakim Tjernlund,
Quoted 9 lines · In message <[email protected]>…
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 rulesSome 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.
Quoted 7 lines
Signed-off-by Joakim Tjernlund <[email protected]>---
- forgot signoff
- removed stray attribute changecommon/dlmalloc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Until you walk a mile in another man's moccasins, you can't imagine the smell.