summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-26 22:08:46 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-26 22:08:46 +0000
commite61f5d8d4ac22d443c28380d48b618c6d1424714 (patch)
tree1defb994dd8309ea6257b05e9811f31f5be8022d
parent6c5446e17360aa1b1bb4067bdbb5f3d9dcd58bd4 (diff)
downloadATCD-e61f5d8d4ac22d443c28380d48b618c6d1424714.tar.gz
(reverse_file): use a local, volatile variable for the array index.
Without it, the test core dumps on LynxOS 3.0.0/PowerPC with -O2.
-rw-r--r--tests/Mem_Map_Test.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp
index 748fff5e105..a1e6fe4bd7c 100644
--- a/tests/Mem_Map_Test.cpp
+++ b/tests/Mem_Map_Test.cpp
@@ -38,16 +38,19 @@ reverse_file (ACE_HANDLE file_handle,
int size)
{
int count = 0;
- size--;
+ // LynxOS 3.0.0/PowerPC needs the volatile qualifier, with
+ // -O2 optimization enabled.
+ volatile int i = size;
+ i--;
- if (array[size] == '\0')
- array[size] = '\n';
+ if (array[i] == '\0')
+ array[i] = '\n';
- while (--size >= 0)
+ while (--i >= 0)
{
- if (array[size] == '\n')
+ if (array[i] == '\n')
{
- ACE_OS::write (file_handle, array + size + 1, count);
+ ACE_OS::write (file_handle, array + i + 1, count);
ACE_OS::write (file_handle, ASYS_TEXT ("\n"), 1);
count = 0;
}