View Issue Details

IDProjectCategoryView StatusLast Update
0037771FPCDocumentationpublic2020-09-18 18:15
Reporter440bx Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformallOSall 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037771: incorrect statement in documentation regarding initialized variables
DescriptionThe web page and, possibly one of the FPC manuals, states the following regarding initialized variables: "For constant records, each element of the record should be specified, in the form Field: Value, separated by semicolons, and surrounded by round brackets."

This is not always the case since a construction such as:

 {$APPTYPE CONSOLE}
{$MODE OBJFPC}
 
type
  TArray = array[0..255] of Byte;
 
  procedure Test1;
  type
    TWrapper = record
      A: TArray;
    end;
  {$PUSH}
  {$WARN 3177 off : Some fields coming after "$1" were not initialized}
  const
    W: TWrapper = ();
  {$POP}
  begin
    Inc(W.A[0]);
    Writeln(W.A[0]);
    //Do something to change a value in W.A;
          { ***** resulting change must be preserved between calls to Test1 ***** }
  end;
 
begin
  Test1;
  Test1;
  Readln;
end.
 
where the field of the record are _not_ specified in the declaration:

  const
    W: TWrapper = ();

Additional InformationSee forum discussion in the thread https://forum.lazarus.freepascal.org/index.php/topic,51461.msg377813.html#msg377813
TagsNo tags attached.
Fixed in Revision1754
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Michael Van Canneyt

2020-09-18 18:15

administrator   ~0125624

Fixed, thanks for reporting. The behaviour of the compiler changed, this used to be forbidden.

Issue History

Date Modified Username Field Change
2020-09-18 14:36 440bx New Issue
2020-09-18 14:36 440bx Status new => assigned
2020-09-18 14:36 440bx Assigned To => Michael Van Canneyt
2020-09-18 18:15 Michael Van Canneyt Status assigned => resolved
2020-09-18 18:15 Michael Van Canneyt Resolution open => fixed
2020-09-18 18:15 Michael Van Canneyt Fixed in Version => 3.3.1
2020-09-18 18:15 Michael Van Canneyt Fixed in Revision => 1754
2020-09-18 18:15 Michael Van Canneyt FPCTarget => 3.2.2
2020-09-18 18:15 Michael Van Canneyt Note Added: 0125624