DWARF Standard


120213.1 Tobias Burnus Allow DW_AT_type with DW_TAG_string_type Enhancement Replaced Kendrick Wong

Section 5.9 String Type Entr, pg 98
The DWARF spec currently does not allow to specify the type (DW_AT_type) for strings (DW_TAG_string_type).

That's a problem for Fortran, where different string types can exists. For instance, GCC's gfortran [since 4.4] has a kind=1 (one byte) and a kind=4 (four bytes, for UCS-4) character type. The NAG compiler (nagfor 5.3) supports besides the one-byte type also UCS-2, UCS-4, and Shift-JIS.

Note: UCS-4 is an (optional) feature of the Fortran 2003 standard (ISO/IEC 1539-1:2004; see also Fortran 2008, ISO/IEC 1539-1:2010).

Note: One could argue that "byte_size" + "DW_AT_string_length" might be sufficient, but that's not optimal.

Fortran 2003 example:

              program character_kind
                use iso_fortran_env
                implicit none
                integer, parameter :: ascii = selected_char_kind ("ascii")
                integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
                character(kind=ascii, len=26) :: alphabet
                character(kind=ucs4,  len=30) :: hello_world
                alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
                hello_world = ucs4_'Hello World and Ni Hao -- ' &
                              // char (int (z'4F60'), ucs4)     &
                              // char (int (z'597D'), ucs4)
                write (*,*) alphabet
                open (output_unit, encoding='UTF-8')
                write (*,*) trim (hello_world)
              end program character_kind


Replaced by 121221.1.

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2007-2017 by DWARF Standards Committee.