[fpc-pascal] Weird absence of compilation error
OBones
obones at free.fr
Thu Mar 21 16:24:05 CET 2013
Gerhard Scholz wrote:
> This must be read as follows:
>
>> function Tmp: Double;
>> begin
>> Result := 10; // there is a semicolon (mispelling?) [statement 1]
> + Element; [statement 2]
>> end;
>
> So, Result becomes 10.
Yes, that's what happens and, yes it's a misspelling by one of our end
users. Basically we use FPC as one of the engines for the scripting part
of one of our applications.
> The next line is a function call without storing the result. The
> leading '+' (plus) is seen as sign; since '+' is neutral, it seems to
> be ignored by the compiler. A '-' (minus) would force some action, so
> it is absolutely wrong at this place.
Thanks for the explanation on the behavior.
> ----- Original Message ----- From: "OBones" <obones at free.fr>
> To: "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
> Sent: Thursday, March 21, 2013 10:53 AM
> Subject: [fpc-pascal] Weird absence of compilation error
>
>
>> Hello all,
>>
>> I'm using FPC 2.6.0 and have the following test program :
>>
>> program test;
>>
>> function Element: Double;
>> begin
>> Result := 4;
>> end;
>>
>> function Tmp: Double;
>> begin
>> Result := 10; + Element;
>> end;
>>
>> begin
>> WriteLn(Tmp);
>> end.
>>
>> And quite surprisingly to me, both ppc386 and pccrossx64 compile it
>> successfully in Delphi mode!
>> What's even weirder is that if I replace the Plus operator by a Minus
>> operator, then the compilation fails.
>> What I was expecting is that the compilation fails in all cases.
>> Is there some flag that I failed to specify?
>>
>> Regards
>> OBones
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list