ra-8.cc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file ra-8.cc
  3. /// @brief Regression test for lvalue exprs in gcc 6.1
  4. // (c) Daniel Llorens - 2016
  5. // This library is free software; you can redistribute it and/or modify it under
  6. // the terms of the GNU Lesser General Public License as published by the Free
  7. // Software Foundation; either version 3 of the License, or (at your option) any
  8. // later version.
  9. // Failed for Expr:: Ryn:: Vector:: =, += ... on gcc 6.1 due to bug 70942. This
  10. // is kept to show why that forward<decltype(y)>(y) is there.
  11. #include <iostream>
  12. #include <iterator>
  13. #include "ra/mpdebug.hh"
  14. #include "ra/complex.hh"
  15. #include "ra/test.hh"
  16. #include "ra/ra.hh"
  17. using std::cout, std::endl, std::flush, std::tuple, ra::TestRecorder;
  18. using real = double;
  19. template <int rank=ra::RANK_ANY> using Ureal = ra::Unique<real, rank>;
  20. template <int rank=ra::RANK_ANY> using Uint = ra::Unique<int, rank>;
  21. int main()
  22. {
  23. TestRecorder tr(std::cout);
  24. // tr.section("gcc 6.1 A");
  25. // {
  26. // // Both must be lvalues [ra05]. FIXME check that these fail [ra42]
  27. // ra::Unique<int, 1> a { 0, 0, 0, 0 };
  28. // ra::Unique<int, 1> b { 0, 0, 0, 0 };
  29. // where(ra::_0>0 && ra::_0<3, ra::_0, a) = 99;
  30. // where(ra::_0>0 && ra::_0<3, a, ra::_0) = 99;
  31. // }
  32. tr.section("gcc 6.1 B");
  33. {
  34. Ureal<1> a {1, 4, 2, 3};
  35. Ureal<1> b({4}, 0.);
  36. b(3-ra::_0) = a;
  37. tr.test_eq(Ureal<1> {3, 2, 4, 1}, b);
  38. }
  39. tr.section("gcc 6.1 C");
  40. {
  41. Ureal<1> a = {1, 2, 3, 4};
  42. Uint<1> i = {3, 1, 2};
  43. a(i) = ra::Unique<real, 1> {7, 8, 9};
  44. tr.test_eq(a, Ureal<1> {1, 8, 9, 7});
  45. }
  46. tr.section("gcc 6.1 D");
  47. {
  48. ra::Big<int, 2> A({4, 4}, 0), B({4, 4}, 10*ra::_0 + ra::_1);
  49. using coord = ra::Small<int, 2>;
  50. ra::Big<coord, 1> I = { coord{1, 1}, coord{2, 2} };
  51. map([&A](auto && c) -> decltype(auto) { return A.at(c); }, I)
  52. = map([&B](auto && c) { return B.at(c); }, I);
  53. tr.test_eq(Ureal<2>({4, 4}, {0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0}), A);
  54. }
  55. return tr.summary();
  56. }