Skip to content

Commit 961b29a

Browse files
committed
Silence GCC 8's warning about using realloc/memmove on non-POD
1 parent 6cd6d31 commit 961b29a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/util/small_map.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ class small_mapt
146146
if(n == 0)
147147
return nullptr;
148148

149-
T *mem = (T *)realloc(ptr, sizeof(T) * n);
149+
// explicitly cast to char * as GCC 8 warns about not using new/delete for
150+
// class sharing_node_innert<dstringt, std::basic_string<char>,
151+
// std::equal_to<dstringt> >
152+
T *mem = (T *)realloc((char *)ptr, sizeof(T) * n);
150153

151154
if(!mem)
152155
throw std::bad_alloc();
@@ -486,7 +489,11 @@ class small_mapt
486489
std::size_t n = size();
487490
if(ii < n - 1)
488491
{
489-
memmove(p + ii, p + ii + 1, sizeof(T) * (n - ii - 1));
492+
// explicitly cast to char * as GCC 8 warns about not using new/delete
493+
// for
494+
// class sharing_node_innert<dstringt, std::basic_string<char>,
495+
// std::equal_to<dstringt> >
496+
memmove((char *)(p + ii), p + ii + 1, sizeof(T) * (n - ii - 1));
490497
}
491498

492499
p = allocate(p, n - 1);

0 commit comments

Comments
 (0)