https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112642

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-11-20

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the libstdc++ code is fine here, suggesting a compiler bug.

Slightly reduced:

#include <string>
#include <vector>

using namespace std;
using namespace std::literals;

struct Fold
{
  template<typename _Iter, typename _Sent, typename _Tp, typename _Fp>
      constexpr auto
      operator()(_Iter, _Sent, _Tp __init, _Fp) const
      {
        return std::move(__init);
      }

    template<typename _Range, typename _Tp, typename _Fp>
      constexpr auto
      operator()(_Range&& __r, _Tp __init, _Fp __f) const
      { return (*this)(__r.begin(), __r.end(), std::move(__init),
std::move(__f)); }

} fold;

constexpr auto foo() {
    const auto vec = vector{ "a"s, "b"s, "c"s };
    return fold(vec, ""s, plus{});
}

constexpr auto bar() {
    return foo().size();
}

int main() {
    constexpr auto _ = bar();
}

Reply via email to