[fpc-pascal] Weird absence of compilation error
Gerhard Scholz
gs at g--s.de
Thu Mar 21 15:10:04 CET 2013
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.
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.
----- 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
More information about the fpc-pascal
mailing list