[Skip Navigation] [Remove Frame] [CS320] [Text Version] c++.semantics.html Sat Dec 23 07:59:52 PST 2006


    C++ Array Semantics?

    > I need to implement inference rules for arrays in axiomatic semantics. Just a few random thoughts...

    One model of an array is as a mapping from the set of indices to the set of values stored in an array. To use this idea in an axiomatic system means that your logic has to be of a higher order calculus than LPC, I guess. I feel that you may be able to avoid any complications for normally declared arrays like

  1. char buffer[20];

    But arrays on the heap will demand them. For example, the statement p=malloc(n) has a precondition that n>0 and a postcondition like this:

  2. either p=NULL
  3. or for some a:0..(n-1)->char( p points_at address(a) )

    I'd hate to see axioms without functional variables that would let you derive the meaning of the following:

  4. typedef double real2real(double);
  5. real2real trig[]= { sin, cos, sin, cos }; (Assuming I got the syntax right).

    My suspicion is that you will be forced into assuming a function space not unlike that used in denotational semantics.