Compiler Warnings / Possible Bugs?

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
markjforte
Posts: 7
Joined: Thu Dec 06, 2012 7:41 pm

Compiler Warnings / Possible Bugs?

Post by markjforte »

Hi Lars,

We are finally upgrading to your XLSReadWriteII 5 (version 5.20.10... note that we bought 5 upgrade licences back in April, but we are only now finding the time to upgrade), and when I build with your source, I see some concerning compiler warnings.

1)
[Warning] BIFF_ReadII5.pas(2906): Variable 'FontRuns' might not have been initialized
[Warning] XLSWriteXLSX5.pas(779): Variable 'FontRuns' might not have been initialized
Looking at TXLSReadII.SSTReadString, I see a "case Options of .. STRID_RICH" block in which FontRuns is set to := ConvertFormatRunsDynFontRuns. However, this is not done within the other blocks (STRID_RICH_UNICODE, STRID_FAREAST_RICH, STRID_FAREAST_RICH_UC), yet within those blocks an uninitilized FontRuns is passed to FManager.SST.AddFormattedString()... Is this by design, or a bug?

2)
[Warning] XLSSheetData5.pas(4396): Variable 'DestXF' might not have been initialized
Looking at TXLSWorkbook.CopyCells, I see that if ANoFormat=True then DestXF is not set, yet in the "if SrcCells.CellType(@Cell) in XLSCellTypeFormulas" block it is referred to... Is this by design, or a bug? I'm concerned that if there is a formula in a cell that is not formatted, this will cause an error?

3)
[Warning] XLSRTFReadWrite5.pas(1086): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1868): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1916): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1916): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1916): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1916): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1917): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1917): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1917): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1917): Comparing signed and unsigned types - widened both operands
[Warning] XLSCmdFormat5.pas(1917): Comparing signed and unsigned types - widened both operands
[Hint] XLSSheetData5.pas(4123): Variable 'Name' is declared but never used in 'TXLSWorkbook.AdjustColumnsFormulas1d'
[Hint] XLSSheetData5.pas(4158): Variable 'Name' is declared but never used in 'TXLSWorkbook.AdjustRowsFormulas1d'
[Hint] XLSSheetData5.pas(4355): Variable 'S' is declared but never used in 'TXLSWorkbook.CopyCells'
These warnings all appear to be benign. However, I'm of the opinion that there should not be any compiler hints or warnigns when a package or project is compiled, otherwise newly introduced imporant ones might be overlooked. Can you update the code to avoid them? For example, I updated this method as follows:

procedure TXLSCmdFormatNumber.SetNegColor(const Value: TColor);
begin
//MJF 2013-12-27: Added casts to avoid [Warning] : Comparing signed and unsigned types - widened both operands
if (Value = XLSUtils5.TColor(clBlack))
or (Value = XLSUtils5.TColor(clFuchsia))
or (Value = XLSUtils5.TColor(clPurple))
or (Value = XLSUtils5.TColor(clWhite))
or (Value = XLSUtils5.TColor(clBlue))
or (Value = XLSUtils5.TColor(clGreen))
or (Value = XLSUtils5.TColor(clRed))
or (Value = XLSUtils5.TColor(clYellow))
or (Value = XLSUtils5.TColor(clDefault))
then begin
FNegColor := Value;
MakeFormatString;
end
else
raise Exception.Create('Invalid negative color');
end;

Thanks!
-Mark
Post Reply