[fpc-devel] Trying to understand the wiki-Page "FPC Unicode support"

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Nov 29 07:55:53 CET 2014

On 28/11/14 21:30, Hans-Peter Diettrich wrote:
> I prefer to specify and document everything *before* coding, so that
> everybody can expect that the code will behave as specified.

If certain behaviour is explicitly undefined, it *is* specified and
documented. It means that your program is buggy if it triggers such
behaviour, and that the effect of triggering it could be anything.

This is standard practice in computer science. E.g., pretty much every
manual of every processor contains descriptions of explicitly undefined
behaviour (search e.g. for "undefined" in the Intel or ARM architecture

An example from FPC itself is accessing an array beyond its bounds when
range checking is switched off. *Some* of the possible outcomes are
accessing a value from a variable declared/before after it, accessing
random data that has nothing to do with any of those variables, a
program crash, or actually accessing an element of the array anyway. We
don't guarantee that any of those possibilities will happen, we don't
say that those are the only possibilities, we don't say they stay the
same across compiler or OS versions, or even across program executions.
Hence, it's undefined.

Exactly the same goes for converting strings with code page CP_NONE to a
different code page: your program is broken when it tries to do that,
and we cannot guarantee any outcome. This is exactly what "the behaviour
is undefined" means.


More information about the fpc-devel mailing list