Skip to content

Conversation

DanBlackwell
Copy link
Contributor

Currently we receive a warning when initializing a ThreadEventCallbacks when compiling with this flag:

llvm-project/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp:252:3: warning: missing field 'start' initializer [-Wmissing-designated-field-initializers]
  252 |   };
      |   ^

This patch explicitly initializes the missing fields to null, fixing the warning.

rdar://162074310

…tializers

Currently we receive a warning when initializing a ThreadEventCallbacks when compiling with this flag:
```
llvm-project/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp:252:3: warning: missing field 'start' initializer [-Wmissing-designated-field-initializers]
  252 |   };
      |   ^
```

This patch explicitly initializes the missing fields to null, fixing the warning.
@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Dan Blackwell (DanBlackwell)

Changes

Currently we receive a warning when initializing a ThreadEventCallbacks when compiling with this flag:

llvm-project/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp:252:3: warning: missing field 'start' initializer [-Wmissing-designated-field-initializers]
  252 |   };
      |   ^

This patch explicitly initializes the missing fields to null, fixing the warning.

rdar://162074310


Full diff: https://github.com/llvm/llvm-project/pull/163401.diff

1 Files Affected:

  • (modified) compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp (+2)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
index 62ab0554df08e..7fa5e017d3985 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -259,7 +259,9 @@ void InitializePlatform() {
 
   ThreadEventCallbacks callbacks = {
       .create = ThreadCreateCallback,
+      .start = nullptr,
       .terminate = ThreadTerminateCallback,
+      .destroy = nullptr,
   };
   InstallPthreadIntrospectionHook(callbacks);
 #endif

.create = ThreadCreateCallback,
.start = nullptr,
.terminate = ThreadTerminateCallback,
.destroy = nullptr,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I thought unmentioned members are guaranteed to be default-initialized.

The semantics of the warning seem to be under discussion:
#68933
#56628

Did this warning pop up with a new version of Clang or was it always there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was picked up by someone building https://github.com/swiftlang/swift (which depends on llvm-project). It seems that they are setting -Wmissing-designated-field-initializers somehow. I rebuilt compiler-rt with the flag and this was the only warning I got, so I figured it's easy enough to clean up. I don't think that the standard llvm CMake build will hit this error, I had to add the flag to my CMAKE_CXX_FLAGS to trigger this.

I agree that this warning feels pedantic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants