incorrect statement in documentation regarding initialized variables
Original Reporter info from Mantis: 440bx @440bx
-
Reporter name:
Original Reporter info from Mantis: 440bx @440bx
- Reporter name:
Description:
The 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 information:
See forum discussion in the thread https://forum.lazarus.freepascal.org/index.php/topic,51461.msg377813.html#msg377813
Mantis conversion info:
- Mantis ID: 37771
- OS: all
- OS Build: all
- Build: all
- Platform: all
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 1754 (#5be9653e)
- Target version: 3.2.2