summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-27 21:49:01 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-27 21:49:01 (GMT)
commit5d5116554d058b58177388ddde7589f7d7b34c51 (patch)
tree31741c7f143988fff6a83f36c773674e63687856 /c++/test
parent4c280b326676380411eecedd03288bd335372565 (diff)
downloadhdf5-5d5116554d058b58177388ddde7589f7d7b34c51.zip
hdf5-5d5116554d058b58177388ddde7589f7d7b34c51.tar.gz
hdf5-5d5116554d058b58177388ddde7589f7d7b34c51.tar.bz2
[svn-r15413] Purpose: Fix bug
Description: Enclosed some code that test reference counts in brackets so that temporary objects will go out of scope before checking references. This is to work around the issue where some C++ compilers destroy temporary objects at different time than others. Platforms tested: SunOS 5.10 (linew) Linux 2.6 (kagiso) FreeBSD (duty)
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/tattr.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index 46eb4f7..74b68ea 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -1048,6 +1048,11 @@ static void test_attr_dtype_shared(void)
// Open the file again
fid1.openFile(FILENAME, H5F_ACC_RDWR);
+ // Enclosing to work around the issue of unused variables and/or
+ // objects created by copy constructors stay around until end of
+ // scope, causing incorrect number of ref counts.
+ { // First enclosed block
+
// Create a datatype to commit and use
IntType dtype(PredType::NATIVE_INT);
@@ -1061,11 +1066,6 @@ static void test_attr_dtype_shared(void)
// Create dataspace for dataset
DataSpace dspace;
- // Enclose the following so that all temporary objects can be
- // destroyed before testing reference count - this is to overcome
- // the different time when the temporary objects are to be destroyed
- // by different compilers.
- {
// Create dataset
DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace);
@@ -1105,11 +1105,15 @@ static void test_attr_dtype_shared(void)
dset.close();
dspace.close();
dtype.close();
+ } // end of first enclosing
+
fid1.close();
// Open the file again
fid1.openFile(FILENAME, H5F_ACC_RDWR);
+ { // Second enclosed block...
+
// Open dataset
DataSet *dset2 = new DataSet (fid1.openDataSet(DSET1_NAME));
@@ -1128,11 +1132,11 @@ static void test_attr_dtype_shared(void)
fid1.getObjinfo(TYPE1_NAME, statbuf);
verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__);
+ } // end of second enclosing
+
// Unlink the dataset
fid1.unlink(DSET1_NAME);
- } // end of enclosing to test reference counts
-
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
verify_val((int)statbuf.nlink, 1, "H5File::unlink", __LINE__, __FILE__);