[fpc-devel] ifthen bugs (maybe)
Martin
fpc at mfriebe.de
Thu Feb 4 05:22:29 CET 2016
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);
More information about the fpc-devel
mailing list