Bug 71641

Summary: Fix warning on signed/unsigned comparison in GfxState.cc
Product: poppler Reporter: Hib Eris <hib>
Component: generalAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: hib
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Fix warning on signed/unsigned comparison in GfxState.cc
Fix warning on signed/unsigned comparison in GfxState.cc

Description Hib Eris 2013-11-15 11:43:36 UTC
Created attachment 89262 [details]
Fix warning on signed/unsigned comparison in GfxState.cc
Comment 1 Albert Astals Cid 2013-11-15 19:04:44 UTC
I don't get this warnings, are you using non poppler-standard warnings?
Comment 2 Hib Eris 2013-11-15 20:11:53 UTC
(In reply to comment #1)
> I don't get this warnings, are you using non poppler-standard warnings?

No, just running ./autogen.sh.

It gives me this:

$ make V=1 GfxState.lo
/bin/bash ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../goo   -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12      -I/usr/include/libpng12    -I/usr/include/freetype2       -fPIC -Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-check-new -fno-common -g -O2 -ansi  -MT GfxState.lo -MD -MP -MF .deps/GfxState.Tpo -c -o GfxState.lo GfxState.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../goo -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libpng12 -I/usr/include/freetype2 -fPIC -Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-check-new -fno-common -g -O2 -ansi -MT GfxState.lo -MD -MP -MF .deps/GfxState.Tpo -c GfxState.cc  -fPIC -DPIC -o .libs/GfxState.o
GfxState.cc: In member function 'virtual void GfxICCBasedColorSpace::getGray(GfxColor*, GfxGray*)':
GfxState.cc:2000:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
GfxState.cc: In member function 'virtual void GfxICCBasedColorSpace::getRGB(GfxColor*, GfxRGB*)':
GfxState.cc:2047:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
GfxState.cc:2090:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
GfxState.cc: In member function 'virtual void GfxICCBasedColorSpace::getCMYK(GfxColor*, GfxCMYK*)':
GfxState.cc:2295:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../goo -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libpng12 -I/usr/include/freetype2 -fPIC -Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions -fno-check-new -fno-common -g -O2 -ansi -MT GfxState.lo -MD -MP -MF .deps/GfxState.Tpo -c GfxState.cc -o GfxState.o >/dev/null 2>&1
mv -f .deps/GfxState.Tpo .deps/GfxState.Plo
Comment 3 Hib Eris 2013-11-16 10:15:33 UTC
Created attachment 89310 [details] [review]
Fix warning on signed/unsigned comparison in GfxState.cc

On second thought, I think it is better to use size_t instead of unsigned int as type of CMSCACHE_LIMIT, because that matches the return type of std:map.size().
Comment 4 Albert Astals Cid 2013-11-18 19:08:07 UTC
Which gcc are you running? My man page of gcc says that -Wsign-compare is enabled by -Wextra which we are not using (and your command line doesn't show either)
Comment 5 Hib Eris 2013-11-19 08:23:54 UTC
$ gcc --version
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


From my man page:

-Wall
           This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to
           prevent the warning), even in conjunction with macros.  This also enables some language-specific warnings described in C++
           Dialect Options and Objective-C and Objective-C++ Dialect Options.

           -Wall turns on the following warning flags:

           -Waddress -Warray-bounds (only with -O2) -Wc++11-compat -Wchar-subscripts -Wenum-compare (in C/Objc; this is on by default in
           C++) -Wimplicit-int (C and Objective-C only) -Wimplicit-function-declaration (C and Objective-C only) -Wcomment -Wformat -Wmain
           (only for C/ObjC and unless -ffreestanding) -Wmaybe-uninitialized -Wmissing-braces -Wnonnull -Wparentheses -Wpointer-sign
           -Wreorder -Wreturn-type -Wsequence-point -Wsign-compare (only in C++) -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs
           -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wvolatile-register-var
Comment 6 Albert Astals Cid 2013-11-19 23:43:45 UTC
It's weird, i'm on gcc 4.8.2 and don't get the warning.

Anyway, i've fixed it to use std::map<unsigned int, unsigned int>::size_type as type which is the real type that cmsCache.size() returns.

Thanks for the report.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.