On 2012-12-02 01:37, Garrett Cooper wrote:
On Sat, Dec 1, 2012 at 3:05 AM, Andriy Gapon <a...@freebsd.org> wrote:
I believe that there is no actual problem there.

     It's probably bugs with clang dealing with alignment problems.

Which bugs?


These warnings (and others) go largely unnoticed because of the fact
that -Werror isn't on on sys/boot. I filed kern/173932 for that and
have been grinding away on warnings for the past couple days in my
spare time -- with my local modifications sys/boot compiles with
-Werror now with gcc, but not clang.
Thanks,
-Garrett

/store/freebsd/head/sys/boot/i386/zfsboot/zfsboot.c:101:24: error:
tentative definition of variable with internal linkage has incomplete
non-array type 'struct zfsmount'
[-Werror,-Wtentative-definition-incomplete-type]
static struct zfsmount zfsmount;
                        ^
/store/freebsd/head/sys/boot/i386/zfsboot/zfsboot.c:101:15: note:
forward declaration of 'struct zfsmount'
static struct zfsmount zfsmount;
               ^

This is just a programming error: struct zfsmount is declared in
zfsimpl.c, but that file is included on line 151, so 50 lines after the
static variable definition.

Either the include should be moved up, or the definition moved down.


In file included from /store/freebsd/head/sys/boot/i386/zfsboot/zfsboot.c:151:
In file included from
/store/freebsd/head/sys/boot/i386/zfsboot/../../zfs/zfsimpl.c:38:
/store/freebsd/head/sys/boot/i386/zfsboot/../../../cddl/boot/zfs/zfssubr.c:207:9:
error: cast from 'char *' to 'zio_eck_t *' (aka 'struct zio_eck *')
increases required alignment from 1 to 4 [-Werror,-Wcast-align]
                 eck = (zio_eck_t *)((char *)data + size) - 1;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Clang is right here, the alignment *is* being increased.  However, on
x86, there is no problem with it, so the warning can be ignored.  On the
other hand, if the code should be portable to alignment-sensitive
arches, the code should be fixed.  The same holds for all the other
alignment warnings.

The difference between gcc and clang is that gcc never seems to warn
about alignment issues on x86.  You must compile the code with a gcc
targeting an alignment-sensitive arch, to get any warnings.  Clang
always warns, when using -Wcast-align.
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to