Bollinger, John C | 22 Sep 2011 19:04

The replace_text tools does not build on GCC 4.1.2 / x86_64


Still being unable to access the PDFedit bug tracker, I hope this is a reasonable location to offer one more
bug report (and a patch).

While attempting to build the 0.4.5 tools on CentOS 5 / x86_64 using the distro's standard CGG 4.1.2
toolchain, I receive the following compilation error:

g++ -c -g -O2   -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fexceptions  
-fstack-protector -pipe -posix -ansi -std=c++98 -I.
-I/home/jbolling/rpm/BUILD/pdfedit-0.4.5/src
-I/home/jbolling/rpm/BUILD/pdfedit-0.4.5/src/xpdf/  -I/usr/include -I/usr/include/freetype2 
-I/usr/include -o replace_text.o replace_text.cc
replace_text.cc: In function 'int main(int, char**)':
replace_text.cc:140: error: no matching function for call to 'min(size_t&, unsigned int)'

The source line in question is the innocuous looking:

               to = std::min(to, pdf->getPageCount()+1);

The problem is that 'to' has type size_t, whereas pdf->getPageCount() has type unsigned int, and these are
not equivalent in the compilation environment.  (size_t is a 64-bit unsigned integer, whereas unsigned
int is only 32 bits wide.)  The problem could, and perhaps should, be fixed by changing the data type of one or
the other of these expressions so that they are compatible, but a quick and not-too-dirty solution is to
just do this:

diff -Naur pdfedit-0.4.5-base/src/tools/replace_text.cc pdfedit-0.4.5-mod/src/tools/replace_text.cc
--- pdfedit-0.4.5-base/src/tools/replace_text.cc        2010-02-23 12:28:09.000000000 -0600
+++ pdfedit-0.4.5-mod/src/tools/replace_text.cc 2011-09-22 11:20:19.000000000 -0500
 <at>  <at>  -137,7 +137,7  <at>  <at> 

(Continue reading)

Michal Hocko | 22 Sep 2011 19:22
Picon

Re: The replace_text tools does not build on GCC 4.1.2 / x86_64

On Thu, Sep 22, 2011 at 12:04:14PM -0500, Bollinger, John C wrote:
> 
> Still being unable to access the PDFedit bug tracker, I hope this is a
> reasonable location to offer one more bug report (and a patch).
>
> While attempting to build the 0.4.5 tools on CentOS 5 / x86_64 using
> the distro's standard CGG 4.1.2 toolchain, I receive the following
> compilation error:
> 
> g++ -c -g -O2   -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fexceptions  
-fstack-protector -pipe -posix -ansi -std=c++98 -I.
-I/home/jbolling/rpm/BUILD/pdfedit-0.4.5/src
-I/home/jbolling/rpm/BUILD/pdfedit-0.4.5/src/xpdf/  -I/usr/include -I/usr/include/freetype2 
-I/usr/include -o replace_text.o replace_text.cc
> replace_text.cc: In function 'int main(int, char**)':
> replace_text.cc:140: error: no matching function for call to 'min(size_t&, unsigned int)'

Yet another gcc 4.1 issue, I would say.
> 
> The source line in question is the innocuous looking:
> 
>                to = std::min(to, pdf->getPageCount()+1);
> 
> The problem is that 'to' has type size_t, whereas pdf->getPageCount()
> has type unsigned int, and these are not equivalent in the compilation
> environment. (size_t is a 64-bit unsigned integer, whereas unsigned
> int is only 32 bits wide.)

This is already fixed in the CVS as:

(Continue reading)


Gmane