HDFGroup / HDFGroup/hdf5

Warning from GCC's -Walloc-size-larger-than= in H5Location.cpp

Open
#5,126 11 comments 1 reaction 1 assignee Claimed by @bmribler View on GitHub
Component - Wrappers
Dominant language
C
Stars
988
Forks
355
Avg merge
4d 2h
Merged PRs (30d)
12

Description

My `g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0` compiler warns me about a dangerous alloc in

https://github.com/HDFGroup/hdf5/blob/ec0d3411333feb614c913dd970332043f35bf763/c%2B%2B/src/H5Location.cpp#L2001

This is the warning I got:

```
hdf5/c++/src/H5Location.cpp:2001:46: warning: argument 1 range [9223372036854775809, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
2001 | char *name_C = new char[actual_name_len]();
| ^
In file included from /usr/include/c++/13/bits/exception_ptr.h:38,
from /usr/include/c++/13/exception:164,
from /usr/include/c++/13/ios:41,
from /usr/include/c++/13/ostream:40,
from /usr/include/c++/13/iostream:41,
from /home/avitase/ravis/core/hdf5/c++/src/H5Location.cpp:13:
/usr/include/c++/13/new:128:26: note: in a call to allocation function ‘void* operator new [](std::size_t)’ declared here
128 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
|
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.