This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ada/2394: print statement does not print access type correctly


>Number:         2394
>Category:       ada
>Synopsis:       print statement does not print access type correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 28 22:38:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Brian Stensrude
>Release:        6.6
>Organization:
>Environment:
Solaris 8
>Description:
when printing a String access type, the index is displayed wrong. For example, the following String "This is a test." will be displayed as "s is test.   ".
Note: This problem is also in GDB 6.7.1.

See example in How-To-Repeat:
>How-To-Repeat:
Build and run the program below in debug. 
Put a breakpoint on the Text_IO.Put_Line.
Do a "print" on myStr.The_String (1...myStr.The_Length) and you will see it is off by 3 characters.

program adatest =>

with Text_IO,
     Unchecked_Deallocation;

procedure adatest is

  type Rec (Max_Length : Positive) is
  record
    The_Length : Natural := 0;
    The_String : String (1..Max_Length) := (Others => ' ');
  end record;

  type BString is access Rec;

  procedure Free is new Unchecked_Deallocation (Rec,  
                                                BString);

  tmpStr : constant String := "This is a test.";
  myStr  : BString := Null;

begin
  myStr := new Rec (50);
  myStr.The_String (1..tmpStr'Length) := tmpStr;
  myStr.The_Length := tmpStr'Length;
  Text_IO.Put_Line(myStr.The_String (1..myStr.The_Length));
  Free (myStr);
end adatest;

compile with "gnatmake -g adatest"
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]