Skip to content

Commit 50f808b

Browse files
committed
Debug: concrete_h5_file_position
dynamic casts can return nullptrs ;-) #471
1 parent 7a3fc53 commit 50f808b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/openPMD/IO/HDF5/HDF5Auxiliary.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <hdf5.h>
2929

3030
#include <stack>
31+
#include <iostream>
3132

3233

3334
namespace openPMD
@@ -253,7 +254,13 @@ concrete_h5_file_position(Writable* w)
253254
std::string pos;
254255
while( !hierarchy.empty() )
255256
{
256-
pos += std::dynamic_pointer_cast< HDF5FilePosition >(hierarchy.top()->abstractFilePosition)->location;
257+
auto afp = hierarchy.top()->abstractFilePosition;
258+
259+
auto afp_h5 = std::dynamic_pointer_cast< HDF5FilePosition >(afp);
260+
if( afp_h5 == nullptr )
261+
std::cerr << "WARNING: invalid file position in writable stack!" << std::endl;
262+
else
263+
pos.append(afp_h5->location);
257264
hierarchy.pop();
258265
}
259266

0 commit comments

Comments
 (0)