Skip to content

Commit 02b426e

Browse files
authored
add pragmas to supress warnings associated with compiler bugs (#316)
1 parent d465242 commit 02b426e

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/MallocBuffer.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,14 @@ class MallocBuffer : public bufferManipulation::VoidBuffer
130130
void reallocate( std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity )
131131
{
132132
LVARRAY_ERROR_IF_NE( space, MemorySpace::host );
133-
134-
#if (defined(__GNUC__) && (__GNUC__ == 8))
135-
// This is a workaround for a GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87544
136-
std::size_t constexpr maxSize = (NumericLimits< std::size_t >::max / sizeof( T )) >> 1;
137-
std::size_t newSpaceSize = math::min( static_cast< std::size_t >(newCapacity), maxSize ) * sizeof( T );
138-
#else
139133
std::size_t newSpaceSize = newCapacity * sizeof( T );
140-
#endif
134+
135+
#pragma GCC diagnostic push
136+
#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
141137
// TODO: If std::is_trivially_copyable_v< T > then we could use std::realloc.
142138
T * const newPtr = reinterpret_cast< T * >( std::malloc( newSpaceSize ) );
139+
#pragma GCC diagnostic pop
140+
143141

144142
std::ptrdiff_t const overlapAmount = math::min( newCapacity, size );
145143
arrayManipulation::uninitializedMove( newPtr, overlapAmount, m_data );

src/arrayManipulation.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ void resize( T * const LVARRAY_RESTRICT ptr,
298298
if( newSize - size > 0 )
299299
{
300300
std::size_t const sizeDiff = integerConversion< std::size_t >( newSize - size );
301+
#pragma GCC diagnostic push
302+
#pragma GCC diagnostic ignored "-Warray-bounds"
303+
#pragma GCC diagnostic ignored "-Wstringop-overflow="
301304
memset( reinterpret_cast< void * >( ptr + size ), 0, ( sizeDiff ) * sizeof( T ) );
305+
#pragma GCC diagnostic pop
302306
}
303307
}
304308
else

0 commit comments

Comments
 (0)