]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/29_atomics/atomic/operators/51811.cc
2e2e9dcfd9677e8b720e2b555832df5621cc7889
1 // { dg-do run { target c++11 } }
2 // { dg-require-atomic-builtins "" }
4 // std::abs from <cstdlib> is not freestanding.
5 // { dg-require-effective-target hosted }
7 // Copyright (C) 2012-2023 Free Software Foundation, Inc.
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
25 #include <cstdlib> //std::abs
26 #include <testsuite_hooks.h>
29 // pointer arithimetic vs. atomic<_Tp*> specialization
34 typedef int value_type
;
36 value_type value
= 42;
37 atomic
<value_type
*> p
, p2
, p3
;
47 ptrdiff_t dist
= reinterpret_cast<char*>(vp
) - reinterpret_cast<char*>(vp2
);
48 VERIFY ( std::abs(dist
) == sizeof(value_type
));
63 ptrdiff_t dist
= reinterpret_cast<char*>(vp
) - reinterpret_cast<char*>(vp2
);
64 VERIFY ( std::abs(dist
) == sizeof(value_type
));
77 ptrdiff_t dist
= reinterpret_cast<char*>(vp
) - reinterpret_cast<char*>(vp2
);
78 VERIFY ( std::abs(dist
) == sizeof(value_type
) * n
);
87 ptrdiff_t dist
= reinterpret_cast<char*>(vp
) - reinterpret_cast<char*>(vp2
);
88 VERIFY ( std::abs(dist
) == sizeof(value_type
) * n
);