From: Jeffrey W. <nol...@gm...> - 2011-09-20 22:12:36
|
On Tue, Sep 20, 2011 at 6:02 PM, Bollinger, John C <Joh...@st...> wrote: > > On Tuesday, September 20, 2011 4:35 PM, Jeffrey Walton wrote: >> On Tue, Sep 20, 2011 at 5:13 PM, Bollinger, John C >> <Joh...@st...> wrote: > > [...] > >> > The most obvious fix would be to change the CInts to CReals, but >> I don't know whether that would cause trouble elsewhere in the >> program.CInt (static_cast<int>(image_size.x)) >> CInt (static_cast<int>(image_size.x)) and CInt >> (static_cast<int>(image_size.y)) ? Otherwise, you might need to >> change >> Tp to float or double (which seems like a lot more work). >> >> Since PDFs are widely abused as vectors (and it is CentOS), you >> might >> want to verify image_size.x and image_size.y are within bounds of >> the >> [integer] data type if you choose to cast. numeric_limits is your >> friend. > > Changing Tp to double is approximately the effect of switching the types from CInt to CReal. Only the lines I showed need to be modified, and the code then compiles fine without any more warnings in that section. The problem is that I'm not sure how to test adequately whether the resulting program works correctly. > > static_cast might do the job, but storing a reference to the result of a cast sounds dubious to me. It might work, but it seems like asking for trouble. OK. CInt should copy construct its object, so I don't believe its retaining an external reference. > Again, though, I'm not sure how to test the result adequately. > > Is there any clear guidance on what this ought to be, or is guess and test the best available approach? Take a look at CInt's data member declaration and see if its a reference. From http://pdfedit.cvs.sourceforge.net/viewvc/pdfedit/pdfedit/src/, I can't tell where it might be hiding. Also, if you can assign a CInt, I would expect that it does not hold an internal integer reference. As for the container that holds the name/value pair, they should be copy constructible. But I'm basing that on STL, and PDF Edit might be doing things differently. Jeff |