Fix __gnu_cxx::_Pointer_adapter for long long arithmetic
* include/ext/pointer.h (_Pointer_adapter): Define operators for pointer arithmetic using long long offsets. * testsuite/ext/ext_pointer/1.cc: Test pointer arithmetic using long long values. From-SVN: r263976
This commit is contained in:
parent
f7e1d19d58
commit
4a559e91b1
|
@ -1,3 +1,10 @@
|
||||||
|
2018-08-30 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* include/ext/pointer.h (_Pointer_adapter): Define operators for
|
||||||
|
pointer arithmetic using long long offsets.
|
||||||
|
* testsuite/ext/ext_pointer/1.cc: Test pointer arithmetic using
|
||||||
|
long long values.
|
||||||
|
|
||||||
2018-08-29 Jonathan Wakely <jwakely@redhat.com>
|
2018-08-29 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
PR libstdc++/31413
|
PR libstdc++/31413
|
||||||
|
|
|
@ -441,6 +441,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned int);
|
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned int);
|
||||||
_CXX_POINTER_ARITH_OPERATOR_SET(long);
|
_CXX_POINTER_ARITH_OPERATOR_SET(long);
|
||||||
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned long);
|
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned long);
|
||||||
|
#ifdef _GLIBCXX_USE_LONG_LONG
|
||||||
|
_CXX_POINTER_ARITH_OPERATOR_SET(long long);
|
||||||
|
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned long long);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Mathematical Manipulators
|
// Mathematical Manipulators
|
||||||
inline _Pointer_adapter&
|
inline _Pointer_adapter&
|
||||||
|
|
|
@ -180,11 +180,25 @@ void test04() {
|
||||||
VERIFY(bPtr3 == aPtr);
|
VERIFY(bPtr3 == aPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that long long values can be used for pointer arithmetic.
|
||||||
|
void test05()
|
||||||
|
{
|
||||||
|
A a[2] = { 1, 2 };
|
||||||
|
A_pointer p = a;
|
||||||
|
A_pointer q = p + 0ull;
|
||||||
|
VERIFY( p == q );
|
||||||
|
q += 0ll;
|
||||||
|
VERIFY( p == q );
|
||||||
|
q += 1ll;
|
||||||
|
VERIFY( q->i == p[1ll].i );
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
test02();
|
||||||
test03();
|
test03();
|
||||||
test04();
|
test04();
|
||||||
|
test05();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue