ra-8.cc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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
  9. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70942. This is kept to show why that
  10. // forward<decltype(y)>(y) is there.
  11. #include <iostream>
  12. #include <iterator>
  13. #include "ra/test.hh"
  14. #include "mpdebug.hh"
  15. using std::cout, std::endl, std::flush, std::tuple, ra::TestRecorder;
  16. using real = double;
  17. template <int rank=ra::ANY> using Ureal = ra::Unique<real, rank>;
  18. template <int rank=ra::ANY> using Uint = ra::Unique<int, rank>;
  19. int main()
  20. {
  21. TestRecorder tr(std::cout);
  22. // tr.section("gcc 6.1 A");
  23. // {
  24. // // Both must be lvalues [ra5]. FIXME check that these fail [ra42]
  25. // ra::Unique<int, 1> a { 0, 0, 0, 0 };
  26. // ra::Unique<int, 1> b { 0, 0, 0, 0 };
  27. // where(ra::_0>0 && ra::_0<3, ra::_0, a) = 99;
  28. // where(ra::_0>0 && ra::_0<3, a, ra::_0) = 99;
  29. // }
  30. tr.section("gcc 6.1 B");
  31. {
  32. Ureal<1> a {1, 4, 2, 3};
  33. Ureal<1> b({4}, 0.);
  34. b(3-ra::_0) = a;
  35. tr.test_eq(Ureal<1> {3, 2, 4, 1}, b);
  36. }
  37. tr.section("gcc 6.1 C");
  38. {
  39. Ureal<1> a = {1, 2, 3, 4};
  40. Uint<1> i = {3, 1, 2};
  41. a(i) = ra::Unique<real, 1> {7, 8, 9};
  42. tr.test_eq(a, Ureal<1> {1, 8, 9, 7});
  43. }
  44. tr.section("gcc 6.1 D");
  45. {
  46. ra::Big<int, 2> A({4, 4}, 0), B({4, 4}, 10*ra::_0 + ra::_1);
  47. using coord = ra::Small<int, 2>;
  48. ra::Big<coord, 1> I = { coord{1, 1}, coord{2, 2} };
  49. map([&A](auto && c) -> decltype(auto) { return A.at(c); }, I)
  50. = map([&B](auto && c) { return B.at(c); }, I);
  51. tr.test_eq(Ureal<2>({4, 4}, {0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0}), A);
  52. }
  53. return tr.summary();
  54. }