File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed
tests/std/tests/GH_005276_system_error_heap-use-after-free Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1725,9 +1725,15 @@ namespace chrono {
1725
1725
1726
1726
_EXPORT_STD class _NODISCARD nonexistent_local_time : public runtime_error {
1727
1727
public:
1728
+ #if _HAS_EXCEPTIONS
1728
1729
template <class _Duration>
1729
1730
nonexistent_local_time(const local_time<_Duration>& _Tp, const local_info& _Info)
1730
1731
: runtime_error(_Make_string(_Tp, _Info)) {}
1732
+ #else
1733
+ template <class _Duration>
1734
+ nonexistent_local_time(const local_time<_Duration>&, const local_info&)
1735
+ : runtime_error("nonexistent local time") {}
1736
+ #endif
1731
1737
1732
1738
private:
1733
1739
template <class _Duration>
@@ -1741,9 +1747,15 @@ namespace chrono {
1741
1747
1742
1748
_EXPORT_STD class _NODISCARD ambiguous_local_time : public runtime_error {
1743
1749
public:
1750
+ #if _HAS_EXCEPTIONS
1744
1751
template <class _Duration>
1745
1752
ambiguous_local_time(const local_time<_Duration>& _Tp, const local_info& _Info)
1746
1753
: runtime_error(_Make_string(_Tp, _Info)) {}
1754
+ #else
1755
+ template <class _Duration>
1756
+ ambiguous_local_time(const local_time<_Duration>&, const local_info&)
1757
+ : runtime_error("ambiguous local time") {}
1758
+ #endif
1747
1759
1748
1760
private:
1749
1761
template <class _Duration>
Original file line number Diff line number Diff line change @@ -470,10 +470,17 @@ private:
470
470
}
471
471
472
472
protected:
473
+ #if _HAS_EXCEPTIONS
473
474
_System_error(error_code _Errcode) : runtime_error(_Errcode.message()), _Mycode(_Errcode) {}
474
475
475
476
_System_error(error_code _Errcode, const string& _Message)
476
477
: runtime_error(_Makestr(_Errcode, _Message)), _Mycode(_Errcode) {}
478
+ #else
479
+ _System_error(error_code _Errcode) : runtime_error("system error"), _Mycode(_Errcode) {}
480
+
481
+ _System_error(error_code _Errcode, const string&)
482
+ : runtime_error("system error"), _Mycode(_Errcode) {}
483
+ #endif
477
484
478
485
error_code _Mycode; // the stored error code
479
486
};
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Microsoft Corporation.
2
+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
+
4
+ RUNALL_INCLUDE ..\usual_20_matrix.lst
5
+ RUNALL_CROSSLIST
6
+ * PM_CL="/D_HAS_EXCEPTIONS=0"
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation.
2
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
+
4
+ #include < cstdio>
5
+ #include < chrono>
6
+ #include < string>
7
+ #include < system_error>
8
+ using namespace std ;
9
+ using namespace chrono ;
10
+
11
+ int main () {
12
+ string str{" abc" };
13
+ error_code ec{2 , system_category ()};
14
+ system_error syserr{ec};
15
+
16
+ ambiguous_local_time alt{local_time<seconds>{}, local_info{}};
17
+
18
+ nonexistent_local_time nlt{local_time<seconds>{}, local_info{}};
19
+
20
+ printf (" %s\n %s\n %s\n " , syserr.what (), alt.what (), nlt.what ());
21
+ }
22
+
You can’t perform that action at this time.
0 commit comments