Skip to content

Commit ed3217e

Browse files
npmillerkbenzie
authored andcommitted
Fix comgr error handling (#18350)
Rearrange switch fallthrough to avoid unassigned error string invoking UB when printed Fixes intel/llvm#18336
1 parent 77c6c33 commit ed3217e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/adapters/hip/common.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line,
6262
const char *ErrorString = nullptr;
6363
const char *ErrorName = nullptr;
6464
switch (Result) {
65-
case AMD_COMGR_STATUS_ERROR:
66-
ErrorName = "AMD_COMGR_STATUS_ERROR";
67-
ErrorString = "Generic error";
68-
break;
6965
case AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT:
7066
ErrorName = "AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT";
7167
ErrorString =
@@ -76,7 +72,11 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line,
7672
ErrorName = "AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES";
7773
ErrorString = "Failed to allocate the necessary resources";
7874
break;
75+
case AMD_COMGR_STATUS_ERROR:
76+
[[fallthrough]];
7977
default:
78+
ErrorName = "AMD_COMGR_STATUS_ERROR";
79+
ErrorString = "Generic error";
8080
break;
8181
}
8282
std::stringstream SS;

0 commit comments

Comments
 (0)