View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001610 | SkyChart | 1-Software | public | 17-01-18 08:47 | 17-01-18 15:43 |
Reporter | Sasa | Assigned To | Patrick Chevalley | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Platform | Linux 32-bit | OS | Kubuntu | OS Version | 16.04 |
Product Version | 3.11 SVN | ||||
Target Version | 4.0 | Fixed in Version | 3.11 SVN | ||
Summary | 0001610: Numerous compilation warnings | ||||
Description | There 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. | ||||
Tags | No tags attached. | ||||
|
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. |
|
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. |
|
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; |
|
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. |
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 |