git: libstand: Fix loop with undefined optimized behavior

John Marino marino at crater.dragonflybsd.org
Tue Feb 10 01:36:32 PST 2015


commit cd1536fbca174a8f9715ff773c2e45370b7cda08
Author: John Marino <draco at marino.st>
Date:   Tue Feb 10 10:32:02 2015 +0100

    libstand: Fix loop with undefined optimized behavior
    
    With gcc 4.8+, libstand fails to build with "interation 8u involved in
    undefined behavior [-Werror=aggressive-loop-optimizations]".  I figured
    out that problem was the code was intentionally defining two fields in
    the same structure with a single loop.
    
    The "name" field is an array of size 8 while the "ext" field is an array
    of size 3.  The loop in question iterated 11 times to initialize both,
    relying on contiguous memory to work.  Apparently this leads to undefined
    behavior, so I altered the line to explicitly define the correct element
    on the correct field.

Summary of changes:
 lib/libstand/dosfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/cd1536fbca174a8f9715ff773c2e45370b7cda08


-- 
DragonFly BSD source repository



More information about the Commits mailing list