Issue 080516.1: Default Array Lower Bounds

Author: Ron Brender
Champion: Ron Brender
Date submitted: 2008-05-16
Date revised:
Date closed:
Type: Extension
Status: Accepted
DWARF Version: 4
See also issue 080422.1 re Ada.

Problem Statement
-----------------

In our on-going efforts to minimize the size of DWARF data where
feasible, it has been suggested that the notion of a default lower
array bound value should be defined for most, if not all, languages
that are officially supported by DWARF (in the sense that they have
a defined DW_LANG_ enumeration value).

After reviewing the set of languages that have DW_LANG_ codes I
make the following proposal for what default lower bound, if
any, should be defined for a DW_TAG_subrange DIE (V3 5.12) that
lacks an explicit DW_AT_lower_bound attribute. Currently only
Fortran, C and C++ have such defaults defined (1, 0 and 0
respectively).


Proposal
--------

Define a default lower bound of 0 for the following languages:

    C
    C++
    D
    Java
    Objective C
    Objective C++
    UPC

Define a default lower bound of 1 for the following languages:

    COBOL
    Fortran
    Modula
    Pascal
    PL/I


Discussion
----------

This change will allow space saving in all implementations that
use DWARF.

This change is upward compatible with DWARF V3.

This proposal addresses those languages that themselves provide a
default lower bound. Most, in fact, allow no other alternative.

Omitted from this proposal is any recommendation for Ada, pending
feedback from Todd Allen. In Ada, an explicit lower bound must always
be specified in the source. It has been suggested that even for Ada,
a DWARF default lower bound specification can/will benefit at least
some implementations and users, even if the choice is sub-optimal.
However, Ada is left for a separate proposal.


Editorial Presentation
----------------------

In Section 5.12/p84, replace the sentences that read "The default
lower bound for C or C++ is 0. For Fortran it is 1." with this:

    "The default lower bound is 0 for C, C++, D, Java, Objectice C,
    Objective C++ and UPC. The default lower bound is 1 for COBOL,
    Fortran, Modula, Pascal and PL/I."

In Section 7.12, pp149-151, add the following second paragraph:

    "Figure 31 also shows the default lower bound value that is
    assumed for an omitted DW_AT_lower_bound attribute in the
    context of a DW_TAG_subrange DIE for each defined language."

Modify Figure 31 by adding a third column for the default lower
bound as in the following (which for simplicity elides repetitious
detail):

        Language name           Value   Default lower bound
        -------------           ------  -------------------
        DW_LANG_C89             0x0001          0
                C               ...             0
                Ada83                           none
                C_plus_plus                     0
                Cobol74                         1
                Cobol85                         1
                Fortran77                       1
                Fortran90                       1
                Pascal83                        1
                Modula2                         1
                Java                            0
                C99                             0
                Ada95                           none
                Fortran95                       1
                PLI                             1
                ObjC                            0
                ObjC_plus_plus                  0
                UPC                             0 
        D               0


====

Accepted as proposed.