Fix regression in Ada aggregate assignment
authorTom Tromey <tromey@adacore.com>
Thu, 7 Jan 2021 13:58:19 +0000 (06:58 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 7 Jan 2021 13:58:19 +0000 (06:58 -0700)
A recent upstream patch of mine caused a regression in aggregate
assignment.  The bug was that add_component_interval didn't properly
update the array contents in one resize case.

I found furthermore that there was no test case that would provoke
this failure.  This patch fixes the bug and introduces a test.

gdb/ChangeLog
2021-01-07  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (add_component_interval): Start loop using vector's
updated size.

gdb/testsuite/ChangeLog
2021-01-07  Tom Tromey  <tromey@adacore.com>

* gdb.ada/assign_arr.exp: Add 'others' test.

gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/assign_arr.exp

index 44dfabf62d43696c81dd84f606857882f3f637e0..dd8c01b710acf13f56beff75d77b993e207c61f8 100644 (file)
@@ -1,3 +1,8 @@
+2021-01-07  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (add_component_interval): Start loop using vector's
+       updated size.
+
 2021-01-06  Tom Tromey  <tromey@adacore.com>
 
        * ada-lang.c (ada_evaluate_subexp) <BINOP_ADD, BINOP_SUB>:
index 3bc7bdd63880b620e5f72690f605e497f6a9b6b9..4751b6eeda3ac9cca58c24239ca2ef42d315abe8 100644 (file)
@@ -9755,7 +9755,7 @@ add_component_interval (LONGEST low, LONGEST high,
   }
        
   indices.resize (indices.size () + 2);
-  for (j = size - 1; j >= i + 2; j -= 1)
+  for (j = indices.size () - 1; j >= i + 2; j -= 1)
     indices[j] = indices[j - 2];
   indices[i] = low;
   indices[i + 1] = high;
index 8d5a2ee4599f707796c3e954a850f3f770f711cf..0f3ef7aaaba5988fcf4490621e5fbb41c6b7576a 100644 (file)
@@ -1,3 +1,7 @@
+2021-01-07  Tom Tromey  <tromey@adacore.com>
+
+       * gdb.ada/assign_arr.exp: Add 'others' test.
+
 2021-01-06  Tom Tromey  <tromey@adacore.com>
 
        * gdb.ada/fixed_points/pck.ads (Delta4): New constant.
index 2c79371732591953c8d7338ee3aaecaf239f0036..ca894f057e24bc881af5decd628a8cecc56d6dff 100644 (file)
@@ -30,3 +30,6 @@ runto "main_p324_051.adb:$bp_location"
 
 gdb_test "print assign_arr_input.u2 :=(0.25,0.5,0.75)" \
          " = \\(0\\.25, 0\\.5, 0\\.75\\)"
+
+gdb_test "print assign_arr_input.u2 :=(0.25, others => 0.125)" \
+         " = \\(0\\.25, 0\\.125, 0\\.125\\)"
This page took 0.041774 seconds and 4 git commands to generate.