ra-8.cc 2.0 KB

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