Skip to content

Commit 0af5839

Browse files
authored
Merge pull request #81477 from compnerd/conwarn
Concurrency: silence warning on Windows
2 parents 25bcfed + cab1f40 commit 0af5839

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/Concurrency/TaskStatus.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,13 @@ void AsyncTask::pushInitialTaskName(const char* _taskName) {
654654
auto taskNameLen = strlen(_taskName);
655655
char* taskNameCopy = reinterpret_cast<char*>(
656656
_swift_task_alloc_specific(this, taskNameLen + 1/*null terminator*/));
657+
#if defined(_WIN32)
658+
static_cast<void>(strncpy_s(taskNameCopy, taskNameLen + 1,
659+
_taskName, _TRUNCATE));
660+
#else
657661
(void) strncpy(/*dst=*/taskNameCopy, /*src=*/_taskName, taskNameLen);
658662
taskNameCopy[taskNameLen] = '\0'; // make sure we null-terminate
663+
#endif
659664

660665
auto record =
661666
::new (allocation) TaskNameStatusRecord(taskNameCopy);

0 commit comments

Comments
 (0)