[U-Boot] warnings from gcc-4.4 build

Detlev Zundel dzu at denx.de
Wed Jul 1 15:53:24 CEST 2009


Hi Kumar,

> When building the MPC8572DS_config w/gcc-4.4 I get:
>
> sys_eeprom.c: In function ‘do_mac’:
> sys_eeprom.c:323: warning: dereferencing type-punned pointer will  
> break strict-aliasing rules
> sys_eeprom.c: In function ‘mac_read_from_eeprom’:
> sys_eeprom.c:395: warning: dereferencing type-punned pointer will  
> break strict-aliasing rules
> ahci.c: In function ‘ata_scsiop_read_capacity10’:
> ahci.c:616: warning: dereferencing type-punned pointer will break  
> strict-aliasing rules
> biosemu.c: In function ‘BE_setVGA’:
> biosemu.c:147: warning: dereferencing type-punned pointer will break  
> strict-aliasing rules
> tsec.c: In function ‘tsec_init’:
> tsec.c:200: warning: dereferencing type-punned pointer will break  
> strict-aliasing rules
> dlmalloc.c: In function ‘malloc_bin_reloc’:
> dlmalloc.c:1502: warning: dereferencing pointer ‘p’ does break strict- 
> aliasing rules
> dlmalloc.c:1502: warning: dereferencing pointer ‘p’ does break strict- 
> aliasing rules
> dlmalloc.c:1499: note: initialized from here
> dlmalloc.c:1502: note: initialized from here
> dlmalloc.c: In function ‘free’:
> dlmalloc.c:2474: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2474: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2474: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2474: note: initialized from here
> dlmalloc.c: In function ‘malloc’:
> dlmalloc.c:2219: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2219: note: initialized from here
> dlmalloc.c:2228: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2228: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2228: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2228: note: initialized from here
> dlmalloc.c:2235: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2235: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2235: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2235: note: initialized from here
> dlmalloc.c:2292: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2292: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2292: warning: dereferencing pointer ‘({anonymous})’ does  
> break strict-aliasing rules
> dlmalloc.c:2292: note: initialized from here

You already fixed quite a few problems in dlmalloc:

commit 57c219ad5d34dd9d49991777a62e3899595f2ec7
Author: Kumar Gala <galak at kernel.crashing.org>
Date:   Wed Jul 30 08:01:15 2008 -0500

    Fix compile warnings in dlmalloc

    The origional code was using on odd reference to get to the first
    real element in av_[].  The first two elements of the array are
    not used for actual bins, but for house keeping.  If we are more
    explicit about how use the first few elements we can get rid of the
    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
    ...
    
    The logic of how this code came to be is:
        bin_at(0) = (char*)&(av_[2]) - 2*SIZE_SZ
    
    SIZE_SZ is the size of pointer, and av_ is arry of pointers so:
        bin_at(0) = &(av_[0])
    
    Going from there to bin_at(0)->fd or bin_at(0)->size should be straight forward.
    
    Signed-off-by: Kumar Gala <galak at kernel.crashing.org>

> xyzModem.c: In function ‘xyzModem_stream_open’:
> xyzModem.c:564: warning: ‘dummy’ is used uninitialized in this function
> xyzModem.c:547: note: ‘dummy’ was declared here
>
> Should would be turning on -fno-strict-aliasing.  The linux kernel has  
> been doing this for some time.

Last time around, i.e. moving to gcc 4.x (as proven by the commit
above), we were able to fix the problems.  Did anything significantly
change in the arguments?

Cheers
  Detlev

-- 
The  mathematician's patterns,  like the  painter's or  the poet's,  must be
beautiful;  the ideas, like the colours or the words, must fit together in a
harmonious way. Beauty is the first test: there is no permanent place in the
world for ugly mathematics.                       -- G. H. Hardy
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de


More information about the U-Boot mailing list