Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable ubsan #3452

Merged
merged 22 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ _STL_DISABLE_CLANG_WARNINGS

_STD_BEGIN

enum _Meta_type { // meta character representations for parser
enum _Meta_type : int { // meta character representations for parser
_Meta_lpar = '(',
_Meta_rpar = ')',
_Meta_dlr = '$',
Expand Down
22 changes: 17 additions & 5 deletions stl/inc/sstream
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public:
const basic_string<_Elem, _Traits, _Alloc2>& _Str, ios_base::openmode _Mode = ios_base::in | ios_base::out)
: basic_stringbuf(_Str, _Mode, _Alloc{}) {}

basic_stringbuf(basic_stringbuf&& _Right, const _Alloc& _Al_) : _Al(_Al_) {
basic_stringbuf(basic_stringbuf&& _Right, const _Alloc& _Al_) : _Mystate(0), _Al(_Al_) {
_Assign_rv(_STD move(_Right));
}
#endif // _HAS_CXX20

basic_stringbuf(basic_stringbuf&& _Right) {
basic_stringbuf(basic_stringbuf&& _Right) : _Mystate(0) {
_Assign_rv(_STD move(_Right));
}

Expand Down Expand Up @@ -269,7 +269,7 @@ protected:

_Mysb::setp(_Newptr, _New_pnext, _Newptr + _Newsize);
if (_Mystate & _Noread) { // maintain eback() == allocated pointer invariant
_Mysb::setg(_Newptr, nullptr, _Newptr);
_Mysb::setg(_Newptr, _Newptr, _Newptr);
} else { // if readable, set the get area to initialized region
_Mysb::setg(_Newptr, _Newptr + (_Mysb::gptr() - _Oldptr), _Seekhigh);
}
Expand Down Expand Up @@ -328,6 +328,12 @@ protected:

pos_type seekoff(
off_type _Off, ios_base::seekdir _Way, ios_base::openmode _Mode = ios_base::in | ios_base::out) override {
const bool _Need_read_but_cannot = (_Mode & ios_base::in) != 0 && (_Mystate & _Noread) != 0;
const bool _Need_write_but_cannot = (_Mode & ios_base::out) != 0 && (_Mystate & _Constant) != 0;
if (_Need_read_but_cannot || _Need_write_but_cannot) {
return pos_type{off_type{-1}};
}

// change position by _Off, according to _Way, _Mode
const auto _Gptr_old = _Mysb::gptr();
const auto _Pptr_old = (_Mystate & _Constant) ? nullptr : _Mysb::pptr();
Expand Down Expand Up @@ -388,6 +394,12 @@ protected:
}

pos_type seekpos(pos_type _Pos, ios_base::openmode _Mode = ios_base::in | ios_base::out) override {
const bool _Need_read_but_cannot = (_Mode & ios_base::in) != 0 && (_Mystate & _Noread) != 0;
const bool _Need_write_but_cannot = (_Mode & ios_base::out) != 0 && (_Mystate & _Constant) != 0;
if (_Need_read_but_cannot || _Need_write_but_cannot) {
return pos_type{off_type{-1}};
}

// change position to _Pos, according to _Mode
const auto _Off = static_cast<streamoff>(_Pos);
const auto _Gptr_old = _Mysb::gptr();
Expand Down Expand Up @@ -440,7 +452,7 @@ protected:
_Mysb::setp(_Pnew, (_State & (_Atend | _Append)) ? _Seekhigh : _Pnew, _Seekhigh);

if (_State & _Noread) { // maintain "_Allocated == eback() points to buffer base" invariant
_Mysb::setg(_Pnew, nullptr, _Pnew);
_Mysb::setg(_Pnew, _Pnew, _Pnew);
}
}

Expand Down Expand Up @@ -469,7 +481,7 @@ protected:

_Mysb::setp(_Pnew, _Next, _End_buffer);
if (_State & _Noread) { // maintain "_Allocated == eback() points to buffer base" invariant
_Mysb::setg(_Pnew, nullptr, _Pnew);
_Mysb::setg(_Pnew, _Pnew, _Pnew);
} else {
_Mysb::setg(_Pnew, _Pnew, _Seekhigh);
}
Expand Down
1 change: 1 addition & 0 deletions tests/std/tests/char8_t_17_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/char8_t_impure_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/char8_t_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/concepts_20_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ PM_CL="/clr /MDd /std:c++20"
# PM_CL="/std:c++latest /permissive- /BE /c /EHsc /MTd"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /permissive- /MD"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MTd /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/concepts_latest_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ PM_CL="/MTd /D_ITERATOR_DEBUG_LEVEL=2 /permissive- /analyze:only /analyze:autolo
# PM_CL="/permissive- /BE /c /MTd"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MD"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MTd /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/impure_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/locale0_implib_cpp_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/strict_concepts_20_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ PM_CL="/clr /MDd /std:c++20"
# PM_CL="/std:c++latest /BE /c /EHsc /MTd"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /MD"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /MTd /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/strict_concepts_latest_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ PM_CL="/MTd /D_ITERATOR_DEBUG_LEVEL=2 /analyze:only /analyze:autolog-"
# PM_CL="/BE /c /MTd"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /MD"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /MTd /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/usual_17_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/usual_20_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ PM_CL="/BE /c /EHsc /MD /std:c++20 /permissive-"
PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /permissive- /MD"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MTd /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/usual_latest_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ PM_CL="/BE /c /MD /permissive-"
PM_CL="/BE /c /MTd /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MD"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MTd /fp:strict"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/std/tests/usual_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/tr1/env.lst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MDd /std:c++17"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++20 /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MTd /std:c++latest /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++latest /permissive- -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/tr1/env_minus_md_idl.lst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive- /w14640 /Zc:threadSafeInit-
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MD /std:c++14 /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MTd /std:c++latest /permissive- /w14640 /Zc:threadSafeInit-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++latest /permissive- /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined"
1 change: 1 addition & 0 deletions tests/tr1/env_minus_pure.lst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MD /std:c++14"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MDd /std:c++17"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MTd /std:c++latest /permissive-"
PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++latest /permissive- -fsanitize=undefined -fno-sanitize-recover=undefined"
6 changes: 3 additions & 3 deletions tests/tr1/tests/chrono/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace {
CHECK_INT(d_i::max(), STD numeric_limits<int>::max());

typedef STD chrono::duration_values<double> d_d;
CHECK_INT(d_d::zero(), 0.0);
CHECK_INT(d_d::min(), STD numeric_limits<double>::lowest());
CHECK_INT(d_d::max(), STD numeric_limits<double>::max());
CHECK_DOUBLE(d_d::zero(), 0.0);
CHECK_DOUBLE(d_d::min(), STD numeric_limits<double>::lowest());
CHECK_DOUBLE(d_d::max(), STD numeric_limits<double>::max());
}

template <class Rep, class Period>
Expand Down
6 changes: 2 additions & 4 deletions tests/tr1/tests/cstddef/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ typedef struct {
} Str;

void test_cpp() { // test C++ header
ptrdiff_t zero = 0;
static char* pc = (char*) zero;
static const STDx size_t offs[] = {offsetof(Str, f1), offsetof(Str, f2), offsetof(Str, f3)};
STDx ptrdiff_t pdiff = &pc[INT_MAX] - &pc[0];
STDx ptrdiff_t pdiff = &offs[2] - &offs[0];
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
wchar_t wc = L'Z';
Str x = {1, {2}, 3};
char* ps = (char*) &x;

CHECK_INT(sizeof(STDx size_t), sizeof(sizeof(char)));
CHECK_INT(pdiff, &pc[INT_MAX] - &pc[0]);
CHECK_INT(pdiff, &offs[2] - &offs[0]);
CHECK_INT(wc, L'Z');
CHECK(offs[0] < offs[1]);
CHECK_INT((long) *(float*) (ps + offs[1]), 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/tr1/tests/streambuf1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Mybuf : public STD streambuf {
}

void setp(char* p) { // set pptr
Mybase::setp(p, nullptr);
Mybase::setp(p, p);
}

char* getp() const { // get pptr
Expand Down
2 changes: 1 addition & 1 deletion tests/tr1/tests/streambuf2/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Mybuf : public STD wstreambuf {
}

void setp(wchar_t* p) { // set pptr
Mybase::setp(p, nullptr);
Mybase::setp(p, p);
}

wchar_t* getp() const { // get pptr
Expand Down
2 changes: 1 addition & 1 deletion tests/tr1/tests/type_traits5/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static void t_add_rvalue_reference() { // test add_rvalue_reference<T> for vario
CHECK_TYPEX(STD add_rvalue_reference<ARR1>::type, ARR1 &&);
}

typedef enum { red, blue, green } color;
enum color : int { red, blue, green };

static void t_make_signed() { // test make_signed<T> for various types
CHECK_TYPE(STD make_signed<signed char>::type, signed char);
Expand Down
1 change: 1 addition & 0 deletions tests/utils/stl/test/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def getDefaultFeatures(config, litConfig):
DEFAULT_FEATURES.append(Feature(name='x86'))

elif litConfig.target_arch.casefold() == 'x64'.casefold():
DEFAULT_FEATURES.append(Feature(name='ubsan'))
DEFAULT_FEATURES.append(Feature(name='edg'))
DEFAULT_FEATURES.append(Feature(name='arch_avx2'))
DEFAULT_FEATURES.append(Feature(name='x64'))
Expand Down
4 changes: 3 additions & 1 deletion tests/utils/stl/test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,10 @@ def _parseFlags(self, litConfig):
self.requires.append('clr_pure') # TRANSITION, GH-798
elif flag[1:] == 'clr':
self.requires.append('clr') # TRANSITION, GH-797
elif flag[1:] == 'fsanitize=undefined':
self.requires.append('ubsan') # available for x64, see features.py
elif flag[1:] == 'BE':
self.requires.append('edg') # available for x86, see features.py
self.requires.append('edg') # available for x64, see features.py
elif flag[1:] == 'arch:AVX2':
self.requires.append('arch_avx2') # available for x86 and x64, see features.py
elif flag[1:] == 'arch:IA32':
Expand Down