New Ghostscript/GhostPDL compiler warnings - 2017-11-20-07:45:03 - 1b64014143a8a571e5dbff3346c6ad902603dda1

[email protected]
Newsgroups gmane.comp.printing.ghostscript.regression
Message-ID <20171120170851.BCEBD20401EF@i7>
Previous Revision: cea5d8a72dab953fe84ab8f7280003d377559fff
 Current Revision: 1b64014143a8a571e5dbff3346c6ad902603dda1

commit 1b64014143a8a571e5dbff3346c6ad902603dda1
Author:     Robin Watts <[email protected]>
AuthorDate: Mon Nov 20 14:33:03 2017 +0000
CommitDate: Mon Nov 20 14:38:01 2017 +0000

    Fix release/debug difference.
    
    In searching for the indeterminism in 11-14.PS, I found that I could
    run the same command line in release and debug builds on peeved, and
    get different results:
    
     touch out1.pgm ref1.pgm && rm out*.pgm ref*.pgm &&
     bin/gs -sOutputFile=ref%d.pgm -dMaxBitmap=10000 -sDEVICE=pgmraw -r300
     -Z: -sDEFAULTPAPERSIZE=letter -dNOPAUSE -dBATCH -K2000000 -dClusterJob
     -dJOBSERVER %rom%Resource/Init/gs_cet.ps cutdown >& ~/log &&
     debugbin/gs -sOutputFile=out%d.pgm -dMaxBitmap=10000 -sDEVICE=pgmraw
     -r300 -Z: -sDEFAULTPAPERSIZE=letter -dNOPAUSE -dBATCH -K2000000
     -dClusterJob -dJOBSERVER %rom%Resource/Init/gs_cet.ps cutdown
     >& ~/log2 && md5sum ref*.pgm out*.pgm && less ~/log ~/log2
    
    After cutting down the file as much as I could, Chris reduced it
    simply to:
    
     3E9 3E9 moveto 1 1 lineto stroke showpage
    
    Thanks for this!
    
    Tracing through the code, I discovered that the difference came down
    to check_diff_overflow, where the release build was assuming that if
    v1 > v0, v0 - v1 < 0, which is acceptable because v0 - v1 has
    overflown, at which point C says the value is unpredictable.
    
    The fix is to detect the overflow before it happens.

base/gxpflat.c



Ghostscript:

new clang warnings (clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)): 

./base/gxpflat.c:274:22: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        return (v0 < min_fixed + v1);
                     ^~~~~~~~~
./base/gxfixed.h:32:20: note: expanded from macro 'min_fixed'
# define min_fixed min_int
                   ^~~~~~~
./base/std.h:65:21: note: expanded from macro 'min_int'
#define min_int (-1 << (ARCH_SIZEOF_INT * 8 - 1))
                 ~~ ^

./base/gxpflat.c:276:22: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        return (v0 > max_fixed + v1);
                     ^~~~~~~~~
./base/gxfixed.h:31:20: note: expanded from macro 'max_fixed'
# define max_fixed max_int
                   ^~~~~~~
./base/std.h:66:19: note: expanded from macro 'max_int'
#define max_int (~min_int)
                  ^~~~~~~
./base/std.h:65:21: note: expanded from macro 'min_int'
#define min_int (-1 << (ARCH_SIZEOF_INT * 8 - 1))
                 ~~ ^


http://miles.ghostscript.com:8080/artifex/1b64014143a8a571e5dbff3346c6ad902603dda1/gs-clang-warnings.txt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.