vyasr opened a new issue, #40252: URL: https://github.com/apache/arrow/issues/40252
### Describe the bug, including details regarding any error messages, version, and platform. The span polyfill includes a SFINAE overload for selecting [which types a span should be constructible from](https://github.com/apache/arrow/blob/apache-arrow-15.0.0/cpp/src/arrow/util/span.h#L61). Currently this implementation includes code that is technically in violation of the standard because it requires querying another constructor of `span<T>` at a point when the type is still incomplete. Other span implementations avoid this kind of templating: here are 1) [Microsoft's GSL implementation](https://github.com/microsoft/GSL/blob/caae4dd0f8343efb879369dcd08a2b18aae59f3b/include/gsl/span#L500-L512) and 2) [cudf's implementation in RAPIDS](https://github.com/rapidsai/cudf/blob/branch-24.04/cpp/include/cudf/utilities/span.hpp#L235). It seems like both clang and gcc allow this particular code to compile from my experiments, but nvcc does not. [Here is an example with the compiler explorer demonstrating the expected failure mode with an even simpler construct](https://godbolt.org/z/9MTjq7b3h) (also showing that the current code compiles, albeit unexpectedly). Prior to Arrow 15 this was not a major issue unless external code tried to use Arrow's span directly. However, after the merge of #38027 span.h is transitively included by `arrow/api.h`, which means that essentially any code including Arrow headers will no longer compile on device. Here's a minimal example: ``` #include <arrow/api.h> int main() { return 0; } ``` And attempting to compile it: ``` (rapids) coder _ ~/local/arrow/span_test $ nvcc test.cu -I ../cpp/install/include/ ../cpp/install/include/arrow/result.h(263): warning #2810-D: ignoring return value type with "nodiscard" attribute Remark: The warnings can be suppressed with "-diag-suppress <warning-number>" ../cpp/install/include/arrow/util/span.h(62): error: incomplete type is not allowed ../cpp/install/include/arrow/record_batch.h(335): warning #2810-D: ignoring return value type with "nodiscard" attribute ../cpp/install/include/arrow/record_batch.h(338): warning #2810-D: ignoring return value type with "nodiscard" attribute ../cpp/install/include/arrow/table.h(244): warning #611-D: overloaded virtual function "arrow::RecordBatchReader::ReadNext" is only partially overridden in class "arrow::TableBatchReader" 1 error detected in the compilation of "test.cu". ``` This issue may be fixed using a different expression analogous to those shown in the other span implementations linked above. ### Component(s) C++ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@arrow.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org