Skip to content

Commit

Permalink
Fix g++-14 warning on uninitialized copying (NVIDIA#2157)
Browse files Browse the repository at this point in the history
```
In function bool cuda::std::__4::__dispatch_memmove(_Up*, _Tp*, size_t)
...
error: *(unsigned char*)(&privatized_decode_op[0]) may be used uninitialized [-Werror=maybe-uninitialized]
...
*(unsigned char*)(&privatized_decode_op[0]) was declared here
 1528 |       PrivatizedDecodeOpT privatized_decode_op[NUM_ACTIVE_CHANNELS]{};
```
  • Loading branch information
bernhardmgruber authored and pciolkosz committed Aug 4, 2024
1 parent 8da8635 commit 8694e94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cub/cub/device/dispatch/dispatch_histogram.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ struct dispatch_histogram
d_output_histograms, d_output_histograms + NUM_ACTIVE_CHANNELS, d_output_histograms_wrapper.begin());
::cuda::std::copy(
typedAllocations, typedAllocations + NUM_ACTIVE_CHANNELS, d_privatized_histograms_wrapper.begin());
// TODO(bgruber): we can probably skip copying the function objects when they are empty
::cuda::std::copy(
privatized_decode_op, privatized_decode_op + NUM_ACTIVE_CHANNELS, privatized_decode_op_wrapper.begin());
::cuda::std::copy(output_decode_op, output_decode_op + NUM_ACTIVE_CHANNELS, output_decode_op_wrapper.begin());
Expand Down Expand Up @@ -844,6 +845,12 @@ public:
// Pass-through bin transform operator
struct PassThruTransform
{
// GCC 14 rightfully warns that when a value-initialized array of this struct is copied using memcpy, uninitialized
// bytes may be accessed. To avoid this, we add a dummy member, so value initialization actually initializes the memory.
#if defined(_CCCL_COMPILER_GCC) && __GNUC__ == 14
char dummy;
#endif

// Method for converting samples to bin-ids
template <CacheLoadModifier LOAD_MODIFIER, typename _SampleT>
_CCCL_HOST_DEVICE _CCCL_FORCEINLINE void BinSelect(_SampleT sample, int& bin, bool valid)
Expand Down

0 comments on commit 8694e94

Please sign in to comment.