Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-07

How to let compiler print waring for the dropped returned-vale

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ZHANG Dao-yuan

E.g.

   function f0: boolean;
   begin
     f0:= false;
   end;
begin
   f0;
end;

the returned value f0 is dropped.
Compile it and the compiler won't print any warning.

Any modifier or cmd option can make the compiler print warning for this case?
(my compiler is 2.4.5 x86_64 Linux)

Reply by email

Jürgen Hestermann
to ZHANG Dao-yuan
Show quoted text 11 lines
E.g. function f0: boolean; begin f0:= false; end; begin f0; end; the returned value f0 is dropped. Compile it and the compiler won't print any warning.

Yes, of course. What do you expect? If you don't use the return value for any purpose it is dropped.

Any modifier or cmd option can make the compiler print warning for this case? (my compiler is 2.4.5 x86_64 Linux)

Yes, there is a compiler switch that lets the compiler show an error when not using function return values. But I don't have it at hand now. Just look into the documentation.

Reply by email

ZHANG Dao-yuan
to Jürgen Hestermann
Jürgen Hestermann wrote 25 lines
ZHANG Dao-yuan schrieb: > E.g. > > function f0: boolean; > begin > f0:= false; > end; > begin > f0; > end; > the returned value f0 is dropped. > Compile it and the compiler won't print any warning. Yes, of course. What do you expect? If you don't use the return value for any purpose it is dropped. > Any modifier or cmd option can make the compiler print warning for > this case? > (my compiler is 2.4.5 x86_64 Linux) > Yes, there is a compiler switch that lets the compiler show an error when not using function return values. But I don't have it at hand now. Just look into the documentation.

Thanks, I've found it. {$x-} or {$ExtendedSyntax off}

Reply by email