possible bug in H5LTdtype_to_text or H5LTtext_to_dtype
- Dominant language
- C
- Stars
- 988
- Forks
- 355
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 12
Description
**Describe the bug**
we ran into a possible bug when using H5LTtext_to_dtype and H5LTdtype_to_text together with "H5T_NATIVE_FLOAT" data type. Please find a short reproducer below. When converting text to data type and data type to text once, all works as expected. But after using "H5T_NATIVE_FLOAT" the next data type is also returned as “H5T_IEEE_F32LE” no matter what the input was.
```
#include
#include
#include
std::string idToName(const hid_t ID) {
if (ID < 0) std::cout << "error" << std::endl;
size_t typeNameLength = 0;
// Make a first call to get the length of the typename
H5LTdtype_to_text(ID, nullptr, H5LT_DDL, &typeNameLength);
// Create a container to save the second call.
std::string returnString;
returnString.resize(typeNameLength);
//H5LTdtype_to_text(ID, returnString.data(), H5LT_DDL, &typeNameLength);
H5LTdtype_to_text(ID, &returnString[0], H5LT_DDL, &typeNameLength);
return returnString;
}
int main(int argc, char** argv) {
// Create a container to save the second call.
std::cout << idToName(H5LTtext_to_dtype("H5T_NATIVE_FLOAT", H5LT_DDL)) << std::endl;
std::cout << idToName(H5LTtext_to_dtype("H5T_NATIVE_INT", H5LT_DDL)) << std::endl;
std::cout << idToName(H5LTtext_to_dtype("H5T_NATIVE_UCHAR", H5LT_DDL)) << std::endl;
std::cout << idToName(H5LTtext_to_dtype("H5T_NATIVE_UCHAR", H5LT_DDL)) << std::endl;
return 0;
}
```
Output:
```
H5T_IEEE_F32LE
H5T_IEEE_F32LE
H5T_STD_I32LE
H5T_STD_U8LE
```
**Expected behavior**
```
H5T_IEEE_F32LE
H5T_STD_I32LE
H5T_STD_U8LE
H5T_STD_U8LE
```
**Platform**
We did some testing and found this issue with HDF5 1.14.5 and 1.14.6 and develop. With HDF5 1.14.2 we do not see this behaviour. We also tried different compilers: GNU13.3.0, Intel 2024.2.0, NVIDIA 24.9-CUDA-12. Unfortunately, we could not yet identify the reason for this behaviour.
OS: Rocky Linux 8
Contributor guide
Assessment
This issue has not been assessed yet.