View Issue Details

IDProjectCategoryView StatusLast Update
0001610SkyChart1-Softwarepublic17-01-18 15:43
ReporterSasa Assigned ToPatrick Chevalley  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformLinux 32-bitOSKubuntuOS Version16.04
Product Version3.11 SVN 
Target Version4.0Fixed in Version3.11 SVN 
Summary0001610: Numerous compilation warnings
DescriptionThere is many compilation warnings, some of them may indicate incorrect behavior in some cases. The most problematic:

- Function result variable does not seem to initialized
- Conversion between ordinals and pointers is not portable
- Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
- Mixing signed expressions and longwords gives a 64bit result
- Local variable "..." of a managed type does not seem to be initialized
- Etc...

I would suggest some code cleaning before 4.0 release, as practically all is under try... except/finally blocks and probably serious bugs (these warning may indicate) cannot be spotted quickly.
TagsNo tags attached.

Activities

Patrick Chevalley

17-01-18 11:11

administrator   ~0003546

Last edited: 17-01-18 11:13

Many of this warning are because fpc is a bit overzealous or as problem to identify variable usage.
For example it complain about uninitialized variable if you call a procedure that return a value in a "var" declaration and you not initialize the variable first.

What I can fix is the conversion message by adding explicit type cast.
 
Just forget to add that when you run in debug mode you get every exception even in try ... except block.

Sasa

17-01-18 12:07

reporter   ~0003547

By the pascal definition, it is not mandatory that variable sent by reference by procedure return changed value. In that case, it is mandatory for clearance to initialize it before any usage (in this case sent by reference). Otherwise, recursive check is necessary by compiler, which may be very difficult/slow.

The same warning will rise with Delphi too.

Sasa

17-01-18 12:59

reporter   ~0003548

This for instance, is a complex method:
Procedure Tf_chart.MeasureDistance(action,x,y:integer);

Compiler complains txt is not initialized at line 2645:
txt:=rsFrom+': "'+MeasureStartName+'" '+rsTo+' "'+MeasureEndName+'"'+tab+rsSeparation+': '+txt;

Indeed, it is hard to find is it of where local variable txt initialized...


This for instance may be logically fine as there is exactly 4 projections, however for compiler that is really suspicious as checked value in case structure is integer:

function Tf_chart.cmd_GetProjection:string;
begin

  case sc.cfgsc.projpole of
    equat : result:='EQUAT';
    altaz : result:='ALTAZ';
    gal : result:='GALACTIC';
    ecl : result:='ECLIPTIC';
  end;

  result := msgOK + blank + result;
end;

Patrick Chevalley

17-01-18 15:43

administrator   ~0003549

This is fixed by revision 3445:
https://sourceforge.net/p/skychart/code/3445

I add a lot of else... to satisfy the compiler, in fact adding a lot of unreachable code. I hope it will no complain about that some day :)

Now, "make clean all" do not show a single warning for the main part of the program and my components.
External components still show a lot of warning but this is not the place to fix them.

Issue History

Date Modified Username Field Change
17-01-18 08:47 Sasa New Issue
17-01-18 11:11 Patrick Chevalley Assigned To => Patrick Chevalley
17-01-18 11:11 Patrick Chevalley Status new => assigned
17-01-18 11:11 Patrick Chevalley Note Added: 0003546
17-01-18 11:13 Patrick Chevalley Note Edited: 0003546
17-01-18 12:07 Sasa Note Added: 0003547
17-01-18 12:59 Sasa Note Added: 0003548
17-01-18 15:43 Patrick Chevalley Status assigned => resolved
17-01-18 15:43 Patrick Chevalley Resolution open => fixed
17-01-18 15:43 Patrick Chevalley Fixed in Version => 3.11 SVN
17-01-18 15:43 Patrick Chevalley Target Version => 4.0
17-01-18 15:43 Patrick Chevalley Note Added: 0003549