[TYPES] Declarative vs imperative

Tjark Weber tjark.weber at gmx.de
Wed Apr 24 05:57:56 EDT 2013


On Tue, 2013-04-23 at 09:49 -0700, Mark Janssen wrote:
> > Well, the C standard does not fully define the meaning of all C
> > programs, e.g. when a program divides by zero. The actual program
> > output may depend on the compiler options. The machine code is
> > usually strictly defined, so in a sense the C compiler fills in
> > gaps.
> Right, re: division by zero, but the program output is still
> deterministic -- the gap was filled before you even wrote your
> program, by the compiler vendor/writer.  A given compiler (say  gcc
> vs. TurboC) could handle the case of division by zero differently, but
> the compiler writer still has to make the design decision what his/her
> compiler will do.  Once that decision is made, it will do the same
> thing every time.  *There is no ambiguity, the gap was filled by the
> compiler designer *prior* to your code.*

What you describe here is called *implementation-defined behavior* in
the C standard. There is quite a list of things that are
implementation-defined, see, e.g.,

In contrast, division by 0 causes *undefined behavior* according to the
C standard. This is a quite different category that gives you no
guarantees about your program's behavior whatsoever. Your compiler
might very well do one thing today and another tomorrow.


More information about the Types-list mailing list