KDM 1.4 RTF Avatar
  1. OMG Issue

KDM14 — KDM does not distinguish between C++ pointer and reference

  • Key: KDM14-166
  • Status: closed  
  • Source: KDM Analytics ( Dr. Nikolai Mansourov)
  • Summary:

    Specification text must be clarified regarding semantics of "pointers".

    Current KDM has PointerType which is aligned with ISO 11404 pointer datatype. This datatype is actually a reference. According to the description of "pointer" datatype in ISO 11404:
    "pointer generates a datatype, called a pointer datatype, each of whose values constitutes a means of reference to values of another datatype, designated the element datatype. The values of a pointer datatype are atomic."

    So, the following C++ int i; int *pi=&i; int & ri=i;
    shall be represented by the same KDM, so "ext" attribute could be used to distinguish between them. The two DataElement can be also distinguished by their initialization.

    IntegerType id="int" name="int"
    PointerType id="tpi" name="pint"
    – ItemUnit id="itpi" type="int" ext="int* tpi"
    PointerType id="tri" name="rint"
    – ItemUnit id="itri" type="int" ext="int& tri"

    StorableUnit id="i" name="i" type="int" ext="int i"
    StorableUnit id="pi" name="pi" type="pint"
    – HasType p
    – HasValue a1

    StorableUnit id="ri" name="ri" type="rint"
    – HasType r
    – HasValue i

    ActionElement id="a1" kind="Ptr"
    – Addresses i

    The corresponding C++ uses are represented by the following KDM:
    i=1;

    ActionElement id="a1" kind="Assign"
    – Reads 1
    – Writes i

    (*pi)=1;

    ActionElement id="a1" kind="PtrReplace"
    – Addresses pi
    – Reads 1
    – Writes itpi

    ri=2;

    ActionElement id="a1" kind="PtrReplace"
    – Addresses ri
    – Reads 2
    – Writes itri

  • Reported: KDM 1.3 — Fri, 23 Jan 2015 21:40 GMT
  • Disposition: Resolved — KDM 1.4
  • Disposition Summary:

    Add example to microKDM chapter

    Add examples to microKDM chapter and revise the text regarding the use of the word "pointer". Correct "pointer" to "pointer or reference" and rephrase any figurative use.

  • Updated: Tue, 12 Jul 2016 14:44 GMT