Skip to content

Commit

Permalink
Bugfix/fix compiler pragma for clang (#317)
Browse files Browse the repository at this point in the history
* change pragma guards to check that the compiler is not clang
  • Loading branch information
rrsettgast authored Feb 12, 2024
1 parent 02b426e commit 1531241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MallocBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ class MallocBuffer : public bufferManipulation::VoidBuffer
LVARRAY_ERROR_IF_NE( space, MemorySpace::host );
std::size_t newSpaceSize = newCapacity * sizeof( T );

#if !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
#endif
// TODO: If std::is_trivially_copyable_v< T > then we could use std::realloc.
T * const newPtr = reinterpret_cast< T * >( std::malloc( newSpaceSize ) );
#if !defined(__clang__)
#pragma GCC diagnostic pop

#endif

std::ptrdiff_t const overlapAmount = math::min( newCapacity, size );
arrayManipulation::uninitializedMove( newPtr, overlapAmount, m_data );
Expand Down
4 changes: 4 additions & 0 deletions src/arrayManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,15 @@ void resize( T * const LVARRAY_RESTRICT ptr,
if( newSize - size > 0 )
{
std::size_t const sizeDiff = integerConversion< std::size_t >( newSize - size );
#if !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow="
#endif
memset( reinterpret_cast< void * >( ptr + size ), 0, ( sizeDiff ) * sizeof( T ) );
#if !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}
}
else
Expand Down

0 comments on commit 1531241

Please sign in to comment.