I don't see this mail in archive so I send it again:

Hi
MSEide+MSEgui must compile without warnings and notes with Free Pascal
default settings. In 3.2 there now are many new warnings because of
setlength().

"
procedure test();
var
 s1: string;
 ar1: array of integer;
begin
 setlength(s1,10);
 setlength(ar1,11);
end;
"
compiled with -O- or -O2 produces the warnings
"
main.pas(48,14) Warning: Local variable "s1" of a managed type does not
seem to be initialized
main.pas(49,15) Warning: Local variable "ar1" of a managed type does not
seem to be initialized
"
compiled with -O- produces the code
"
MAIN_$$_TEST:
.Lc1:
.Ll1:
        leaq    -120(%rsp),%rsp
.Lc3:
.Ll2:
        movq    $0,(%rsp)
        movq    $0,8(%rsp)
        leaq    16(%rsp),%rdx
        leaq    40(%rsp),%rsi
        movl    $1,%edi
        call    fpc_pushexceptaddr
        movq    %rax,%rdi
        call    fpc_setjmp
        movslq  %eax,%rdx
        movq    %rdx,104(%rsp)
        testl   %eax,%eax
        jne     .Lj6
.Ll3:
        movq    %rsp,%rdi
        xorl    %edx,%edx
        movl    $10,%esi
        call    fpc_ansistr_setlength
.Ll4:
        movq    $11,112(%rsp)
        movq    $RTTI_$MSETYPES_$$_INTEGERARTY,%rsi
        leaq    112(%rsp),%rcx
        leaq    8(%rsp),%rdi
        movl    $1,%edx
        call    fpc_dynarray_setlength
"
-O3 has no warnings but but doesn't work well for debugging and is not
the Free Pascal default.

"
procedure test();
var
 s1: string = '';
 ar1: array of integer = nil;
begin
 setlength(s1,10);
 setlength(ar1,11);
end;
"
with -O3 (or -O-) produces redundant code:
"
MAIN_$$_TEST:
.Lc1:
.Ll1:
        leaq    -120(%rsp),%rsp
.Lc3:
.Ll2:
        movq    $0,(%rsp)
        movq    $0,8(%rsp)
        leaq    16(%rsp),%rdx
        leaq    40(%rsp),%rsi
        movl    $1,%edi
        call    fpc_pushexceptaddr
        movq    %rax,%rdi
        call    fpc_setjmp
        movslq  %eax,%rdx
        movq    %rdx,104(%rsp)
        testl   %eax,%eax
        jne     .Lj6
.Ll3:
        movq    $RTTI_$MSETYPES_$$_INTEGERARTY,%rdx ----redundant
        movq    TC_$MAIN$_$TEST_$$_defaultar1,%rsi
        leaq    8(%rsp),%rdi
        call    fpc_dynarray_assign
        movq    TC_$MAIN$_$TEST_$$_defaults1,%rsi
        movq    %rsp,%rdi
        call    fpc_ansistr_assign                  ----redundant
.Ll4:
        movq    %rsp,%rdi
        xorl    %edx,%edx
        movl    $10,%esi
        call    fpc_ansistr_setlength
.Ll5:
        movq    $11,112(%rsp)
        movq    $RTTI_$MSETYPES_$$_INTEGERARTY,%rsi
        leaq    112(%rsp),%rcx
        leaq    8(%rsp),%rdi
        movl    $1,%edx
        call    fpc_dynarray_setlength
"
I don't like to initialize the variables in user code anyway because it
misleadingly implies that the initial values of the variables will be used.

In order to suppress the unwanted messages I added
"
{$ifndef mse_allwarnings}
 {$if fpc_fullversion >= 030100}
  {$warn 5089 off}
  {$warn 5090 off}
  {$warn 5093 off}
  {$warn 6058 off}
 {$endif}
{$endif}
"
on top of the units but that does not work for compiling with -B. I was
not able to make a simple testcase, compiling MSEide with -B shows
the suppressed warnings. The code is here:
https://gitlab.com/mseide-msegui/mseide-msegui/tree/fpc_3_2
I do not dare to open a bug report with such a testcase.

Suggestions?

Thanks, Martin
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to