Skip to content

Commit 1531241

Browse files
authored
Bugfix/fix compiler pragma for clang (#317)
* change pragma guards to check that the compiler is not clang
1 parent 02b426e commit 1531241

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/MallocBuffer.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ class MallocBuffer : public bufferManipulation::VoidBuffer
132132
LVARRAY_ERROR_IF_NE( space, MemorySpace::host );
133133
std::size_t newSpaceSize = newCapacity * sizeof( T );
134134

135+
#if !defined(__clang__)
135136
#pragma GCC diagnostic push
136137
#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
138+
#endif
137139
// TODO: If std::is_trivially_copyable_v< T > then we could use std::realloc.
138140
T * const newPtr = reinterpret_cast< T * >( std::malloc( newSpaceSize ) );
141+
#if !defined(__clang__)
139142
#pragma GCC diagnostic pop
140-
143+
#endif
141144

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

src/arrayManipulation.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,15 @@ 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+
#if !defined(__clang__)
301302
#pragma GCC diagnostic push
302303
#pragma GCC diagnostic ignored "-Warray-bounds"
303304
#pragma GCC diagnostic ignored "-Wstringop-overflow="
305+
#endif
304306
memset( reinterpret_cast< void * >( ptr + size ), 0, ( sizeDiff ) * sizeof( T ) );
307+
#if !defined(__clang__)
305308
#pragma GCC diagnostic pop
309+
#endif
306310
}
307311
}
308312
else

0 commit comments

Comments
 (0)