[fpc-devel] ifthen bugs (maybe)

Sven Barth pascaldragon at googlemail.com
Thu Feb 4 08:00:25 CET 2016


Am 04.02.2016 05:46 schrieb "Martin" <fpc at mfriebe.de>:
>
> just found some issues
>
> Neither syntax works in constant evaluation.
> Not sure if they should, so asking here (the 2nd syntax is operator like,
so kind of expected it would)
>
> both cause an internal error trying to take the address of the returned
candidate.
> Then again this might not be a valid operation, but instead of internal
error it should then give a more proper error.
>
> program Project1;
> {$mode objfpc}
> const a = 1 + 2;
> //const a = ifthen(true, 1,2);
> //const a = if true then 1 else 2;
> var b: integer;
> var x : pointer;
> begin
>   //x :=  @( if false then b else b);  // internal error
>   //x :=  @( ifthen( false , b , b));  // internal error
>   writeln(a);
>   writeln(ptrint(x));
>   readln;
> end.
>
>
> Another internal error when using with the in operator.
> program Project1;
> {$mode objfpc}
> var b: integer;
> begin
>   b := 1;
>   writeln(b in [1,2] );
>   //writeln(b in ifthen( true , [1,2] , [3.4])); // internal error
>   //writeln(b in if true then [1,2] else [3.4]);  // internal error
>   readln;
> end.
>
>
> And this compiles, but nothing get incremented.
> If it should not work, then should it give an error?
> (such as "variable identifier expected" which you get when you try to
pass other not incrementable expressions )
>
> program Project1;
> {$mode objfpc}
> var b: integer;
> begin
>   b := 0;
>   writeln(b);
>   inc( if true then b else b );
>   writeln(b);
>   inc( ifthen( true ,b ,b ));
>   writeln(b);
>   readln;
> end.
>
> same with readln
>   readln( if true then b else b   );
>   writeln(b);
>   readln( ifthen( true ,b ,b ));
>   writeln(b);

Would you please report all three of them? I don't necessarily know the
best solution for problems 1 and 3, but internal errors definitely aren't
the answer...

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160204/05e14d64/attachment.html>


More information about the fpc-devel mailing list