Skip to content

Commit

Permalink
Fix compile error in binaryop/compiled/util.cpp (NVIDIA#10209)
Browse files Browse the repository at this point in the history
This PR fixes a compile error in `binaryop/compiled/util.cpp`, when a function with return type `std::optional` return `{}` instead of `std::nullopt`. As such, nvcc 11.5/g++-10.3 yell:
```
../src/binaryop/compiled/util.cpp: In function 'std::optional<cudf::data_type> cudf::binops::compiled::get_common_type(cudf::data_type, cudf::data_type, cudf::data_type)':
../src/binaryop/compiled/util.cpp:48:15: error: '<anonymous>' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   48 |       return {};
      |               ^
```

Authors:
  - Nghia Truong (https://github.com/ttnghia)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)
  - Karthikeyan (https://github.com/karthikeyann)
  - MithunR (https://github.com/mythrocks)
  - Bradley Dice (https://github.com/bdice)

URL: rapidsai/cudf#10209
  • Loading branch information
ttnghia authored Feb 3, 2022
1 parent 8fbd797 commit 0581975
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cpp/src/binaryop/compiled/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ struct common_type_functor {
// Eg. d=t-t
return data_type{type_to_id<TypeCommon>()};
}
return {};

// A compiler bug may cause a compilation error when using empty initializer list to construct
// an std::optional object containing no `data_type` value. Therefore, we should explicitly
// return `std::nullopt` instead.
return std::nullopt;
}
};
template <typename TypeLhs, typename TypeRhs>
Expand Down

0 comments on commit 0581975

Please sign in to comment.