ra-11.C 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file ra-11.C
  3. /// @brief Reduce a bug in gcc 8.3
  4. // (c) Daniel Llorens - 2013-2015
  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. #include <iostream>
  10. #include <iterator>
  11. #include <numeric>
  12. #include <type_traits>
  13. #include "ra/test.H"
  14. #include "ra/ra.H"
  15. #include "ra/mpdebug.H"
  16. using std::cout, std::endl, std::flush;
  17. int main()
  18. {
  19. TestRecorder tr(std::cout);
  20. {
  21. double b[6] = { 1, 2, 3, 4, 5, 6 };
  22. ra::View<double> ra { {6}, b };
  23. tr.test_eq(b, ra);
  24. ra::Unique<double> A({2, 3}, 0);
  25. tr.test_eq(ra::Small<ra::dim_t, 2> {2, 3}, shape(iter<-2>(A)));
  26. tr.test_eq(ra::Small<ra::dim_t, 1> {2}, shape(iter<-1>(A)));
  27. double pool[6] = { 1, 2, 3, 4, 5, 6 };
  28. ra::Unique<double> u({3, 2}, pool, pool+6);
  29. tr.test(std::equal(pool, pool+6, u.begin()));
  30. ra::Unique<double> q(ra::scalar(44));
  31. tr.test_eq(1, q.size());
  32. double rpool[6] = { 1, 2, 3, 4, 5, 6 };
  33. ra::View<double, 2> r { {{3, 1}, {2, 3}}, rpool };
  34. double rcheck[6] = { 1, 4, 2, 5, 3, 6 };
  35. tr.test(std::equal(rcheck, rcheck+6, r.at(ra::Big<int>({0}, {})).begin()));
  36. }
  37. return tr.summary();
  38. }
  39. // copy ra-0.C to dum0.C and
  40. // git bisect run sh -c '/opt/gcc-8.3/bin/g++ -o src/ext/ra/test/dum0 -std=c++17 -Wall -Werror -fdiagnostics-color=always -Wno-unknown-pragmas -finput-charset=UTF-8 -fextended-identifiers -Wno-error=strict-overflow -Werror=zero-as-null-pointer-constant -O3 -march=native -Isrc/ext/ra -Isrc/ext/ra/test src/ext/ra/test/dum0.C && src/ext/ra/test/dum0'
  41. // ffe9bff53c03289514844e957d56ac030b3114e8