[U-Boot-Users] [PATCH] Squash warnings from pointer aliasing in dlmalloc

Kumar Gala galak at kernel.crashing.org
Thu Jun 5 06:37:42 CEST 2008


When we building with gcc-4.3.x on a ppc host we get the following warnings:

dlmalloc.c: In function 'malloc_extend_top':
dlmalloc.c:1971: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:1999: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2029: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2031: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2042: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c: In function 'malloc':
dlmalloc.c:2245: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2245: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2253: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2258: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2263: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2318: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2327: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2329: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2344: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2356: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2360: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2362: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2363: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c: In function 'free':
dlmalloc.c:2431: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2444: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2483: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2483: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c: In function 'realloc':
dlmalloc.c:2594: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2599: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2604: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2605: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2637: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2646: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2647: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c: In function 'calloc':
dlmalloc.c:2896: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2897: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c: In function 'malloc_trim':
dlmalloc.c:2987: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:2997: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:3008: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:3012: warning: dereferencing type-punned pointer will break strict-aliasing rules
dlmalloc.c:3021: warning: dereferencing type-punned pointer will break strict-aliasing rules

This is due to pointer aliasing that the dlmalloc code does and depends on.
Instead of trying trying to work around the warnings, we use the per file
CFLAGs to disable the warnings via -fno-strict-aliasing.

Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
---
 common/Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index b425795..5f4959a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -104,6 +104,7 @@ COBJS-y += console.o
 COBJS-y += cyclon2.o
 COBJS-y += stratixII.o
 COBJS-y += devices.o
+CFLAGS_dlmalloc.o += -fno-strict-aliasing
 COBJS-y += dlmalloc.o
 COBJS-y += docecc.o
 COBJS-y += environment.o
-- 
1.5.5.1





More information about the U-Boot mailing list