pr68397.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // { dg-do run { target c++11 } }
  2. // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
  3. // Copyright (C) 2017-2022 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library. This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10. //
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License along
  17. // with this library; see the file COPYING3. If not see
  18. // <http://www.gnu.org/licenses/>.
  19. // PR libstdc++/68397 - std::tr1::expint fails in __expint_En_cont_frac
  20. // for some long double arguments due to low __max_iter value
  21. #include <cmath>
  22. #include <testsuite_hooks.h>
  23. void
  24. test01()
  25. {
  26. // Answers from Wolfram Alpha.
  27. long double ans_ok = -0.10001943365331651406888645149537315243646135979573L;
  28. long double ans_bomb = -0.10777727809650077516264612749163100483995270163783L;
  29. auto Ei_ok = std::expint(-1.500001L);
  30. auto diff_ok = Ei_ok - ans_ok;
  31. VERIFY(std::abs(diff_ok) < 1.0e-15);
  32. auto Ei_bomb = std::expint(-1.450001L);
  33. auto diff_bomb = Ei_bomb - ans_bomb;
  34. VERIFY(std::abs(diff_bomb) < 1.0e-15);
  35. }
  36. int
  37. main()
  38. {
  39. test01();
  40. return 0;
  41. }