serge-sans-paille / pythran

Ahead of Time compiler for numeric kernels
https://pythran.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.01k stars 193 forks source link

Assert on windows for empty arrays in nested_container_size #2066

Closed jeanlaroche closed 1 year ago

jeanlaroche commented 1 year ago

I don't have a small repro for this as we found it while incorporating the pythran C++ code into our codebase. But it looks like in utils/nested_container.hpp , the function

  template <class T>
  long nested_container_size<T>::flat_size(T const &t)
  {
    return t.size() *
           nested_container_size<typename std::conditional<
               // If we have a scalar or a complex, we want to stop
               // recursion, and then dispatch to bool specialization
               types::is_dtype<typename Type::value_type>::value, bool,
               typename Type::value_type>::type>::flat_size(*t.begin());
  }

Throws an assert if t.size() is zero (because of the call to t.begin()). I will submit a PR for this.

serge-sans-paille commented 1 year ago

Closed by 3f4907910c6fb87ed2f142436c29ebb7313b07ea