Sign in Join

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

Mailing lists / fpc-pascal / 2012-11

chr does not return an error when number bigger then byte enters

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

ik

Hello,

I'ved started a crossaide against PHP
(http://idkn.wordpress.com/2012/11/14/why-php-must-be-abandoned-in-my-opinion/), due to few issues it have such as chr(256) will return ascii "0". But then I tested it with FPC, and it acts exactly the same, while many programming languages report on such value range check error.

begin
  writeln(chr(256)); // because it is constant, the compiler only yell warning
end.

Why does FPC allow such value to enter chr without raising something up ?

Ido

Reply by email

Jonas Maebe
to ik
ik wrote 5 lines
begin writeln(chr(256)); // because it is constant, the compiler only yell warning end. Why does FPC allow such value to enter chr without raising something up ?

You can get an error by enabling range checking (-Cr on the command line or {$r+} in the source code).

Jonas

Reply by email