seanbaxter / circle

The compiler is available for download. Get it!
http://www.circle-lang.org/
2.35k stars 72 forks source link

regression in 195 (from 194), this in decltype #166

Closed correaa closed 1 year ago

correaa commented 1 year ago

Hi,

I noticed a regression when going from 194 to 195.

With circle 195: https://gitlab.com/correaa/boost-multi/-/jobs/4302181279#L580 No error with 194: https://gitlab.com/correaa/boost-multi/-/jobs/4302181271#L543

instantiation: /builds/correaa/boost-multi/include/multi/array_ref.hpp:733:1
during instantiation of class template boost::multi::basic_array
template arguments: [
  'T' = std::complex<double>
    class 'complex' declared at /usr/include/c++/12/complex:1229:5
  'D' = boost::multi::dimensionality_type 2l
  'ElementPtr' = std::complex<double>*
    class 'complex' declared at /usr/include/c++/12/complex:1229:5
  'Layout' = boost::multi::layout_t<2l, long>
    class 'layout_t' declared at /builds/correaa/boost-multi/include/multi/detail/layout.hpp:496:1
]
struct basic_array 
^
  instantiation: /builds/correaa/boost-multi/include/multi/array_ref.hpp:330:1
  during instantiation of class template boost::multi::array_iterator
  template arguments: [
    'Element' = std::complex<double>
      class 'complex' declared at /usr/include/c++/12/complex:1229:5
    'D' = boost::multi::dimensionality_type 2l
    'ElementPtr' = std::complex<double>*
      class 'complex' declared at /usr/include/c++/12/complex:1229:5
  ]
  struct array_iterator  // NOLINT(fuchsia-multiple-inheritance) 
  ^
    instantiation: /builds/correaa/boost-multi/include/multi/array_ref.hpp:1736:1
    during instantiation of partial template boost::multi::basic_array<T, 1, ElementPtr, Layout>
    template arguments: [
      'T' = std::complex<double>
        class 'complex' declared at /usr/include/c++/12/complex:1229:5
      'ElementPtr' = std::complex<double>*
        class 'complex' declared at /usr/include/c++/12/complex:1229:5
      'Layout' = boost::multi::layout_t<1l, long>
        class 'layout_t' declared at /builds/correaa/boost-multi/include/multi/detail/layout.hpp:496:1
    ]
    struct basic_array<T, 1, ElementPtr, Layout>  // NOLINT(fuchsia-multiple-inheritance) : to define operators via CRTP 
    ^
      error: /builds/correaa/boost-multi/include/multi/array_ref.hpp:2220:42
      no viable candidates in call to 'size'
        object is lvalue boost::multi::basic_array<std::complex<double>, 1l, std::complex<double>*, boost::multi::layout_t<1l, long>>
        ->decltype(adl_copy_n(first, this->size(), std::declval<iterator>()), void()) { 
                                               ^
        candidate: auto boost::multi::layout_t<1l, long>::size() const noexcept -> long
        /builds/correaa/boost-multi/include/multi/detail/layout.hpp:604:25
                 constexpr auto size()        const        noexcept -> size_type { 
                                ^
          error: /builds/correaa/boost-multi/include/multi/array_ref.hpp:2220:42
          ... included from /builds/correaa/boost-multi/include/multi/array.hpp:7:10
          ... included from /builds/correaa/boost-multi/test/array_cref.cpp:7:10
          could not bind implicit object parameter
correaa commented 1 year ago

I worked around this by removing the use of this-> in the return type. Not being allowed to use this in decltype in member signatures, seems reasonable too. (Thank you for forcing me to improve my library code)

before:

    template<class It> constexpr auto assign(It first) &&
    ->decltype(adl_copy_n(first, this->size(), std::declval<iterator>()), void()) {
        return adl_copy_n(first, this->size(), std::move(*this).begin()), void(); }

after:

    template<class It> constexpr auto assign(It first) &&
    ->decltype(adl_copy_n(first, std::declval<size_type>(), std::declval<iterator>()), void()) {
        return adl_copy_n(first, this->       size()      , std::move(*this).begin()), void(); }

This solves the problem both for 195 and 198.