|
15 | 15 | namespace sycl { |
16 | 16 | __SYCL_INLINE_VER_NAMESPACE(_V1) { |
17 | 17 |
|
18 | | -namespace { // anonymous |
19 | | -constexpr char ReservedForErrorcode[] = |
20 | | - "01234567812345678"; // 17 (string terminator plus error code) |
21 | | -std::error_code SYCL121ProxyErrorcode = make_error_code(sycl::errc::invalid); |
22 | | -} // namespace |
23 | | - |
24 | 18 | exception::exception(std::error_code EC, const char *Msg) |
25 | 19 | : exception(EC, nullptr, Msg) {} |
26 | 20 |
|
@@ -65,35 +59,11 @@ exception::exception(context Ctx, int EV, const std::error_category &ECat) |
65 | 59 | // protected base constructor for all SYCL 2020 constructors |
66 | 60 | exception::exception(std::error_code EC, std::shared_ptr<context> SharedPtrCtx, |
67 | 61 | const std::string &WhatArg) |
68 | | - : MMsg(std::make_shared<std::string>(WhatArg + ReservedForErrorcode)), |
69 | | - MPIErr(PI_ERROR_INVALID_VALUE), MContext(SharedPtrCtx) { |
70 | | - // For compatibility with previous implementation, we are "hiding" the |
71 | | - // std::error_code in the MMsg string, behind the null string terminator |
72 | | - const int StringTermPoint = MMsg->length() - strlen(ReservedForErrorcode); |
73 | | - char *ReservedPtr = &(*MMsg)[StringTermPoint]; |
74 | | - ReservedPtr[0] = '\0'; |
75 | | - ReservedPtr++; |
76 | | - // insert error code |
77 | | - std::error_code *ECPtr = reinterpret_cast<std::error_code *>(ReservedPtr); |
78 | | - memcpy(ECPtr, &EC, sizeof(std::error_code)); |
79 | | -} |
| 62 | + : MMsg(std::make_shared<std::string>(WhatArg)), |
| 63 | + MPIErr(PI_ERROR_INVALID_VALUE), MContext(SharedPtrCtx), MErrC(EC) {} |
80 | 64 |
|
81 | 65 | const std::error_code &exception::code() const noexcept { |
82 | | - const char *WhatStr = MMsg->c_str(); |
83 | | - // advance to inner string-terminator |
84 | | - int StringTermPoint = MMsg->length() - strlen(ReservedForErrorcode); |
85 | | - if (StringTermPoint >= 0) { |
86 | | - const char *ReservedPtr = &WhatStr[StringTermPoint]; |
87 | | - // check for string terminator, which denotes a SYCL 2020 exception |
88 | | - if (ReservedPtr[0] == '\0') { |
89 | | - ReservedPtr++; |
90 | | - const std::error_code *ECPtr = |
91 | | - reinterpret_cast<const std::error_code *>(ReservedPtr); |
92 | | - return *ECPtr; |
93 | | - } |
94 | | - } |
95 | | - // else the exception originates from some SYCL 1.2.1 source |
96 | | - return SYCL121ProxyErrorcode; |
| 66 | + return MErrC; |
97 | 67 | } |
98 | 68 |
|
99 | 69 | const std::error_category &exception::category() const noexcept { |
|
0 commit comments