[runtime] Adopt safer native compiler flags: report numerous other warnings by rolfbjarne · Pull Request #24093 · dotnet/macios · GitHub
Skip to content

[runtime] Adopt safer native compiler flags: report numerous other warnings#24093

Merged
rolfbjarne merged 10 commits into
mainfrom
dev/rolf/safer-flags-extra-warnings
Oct 28, 2025
Merged

[runtime] Adopt safer native compiler flags: report numerous other warnings#24093
rolfbjarne merged 10 commits into
mainfrom
dev/rolf/safer-flags-extra-warnings

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

None of these warnings trigger in our code base at the moment.

References:

Contributes towards #23023.

Example warning:

```
macios/runtime/xamarin/runtime.h:232:14: error: 'const' type qualifier on return type has no effect [-Werror,-Wignored-qualifiers]
  232 | const char * const      xamarin_get_original_working_directory_path ();
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
Example warning:

```
In file included from macios/appex-deduplicate-frameworks/macios/runtime/runtime.m:98:
macios/runtime/delegates.inc:189:41: error: missing field 'register_assembly' initializer [-Werror,-Wmissing-field-initializers]
  189 | static struct Delegates delegates = { 0 };
      |                                         ^
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
…atch (#24072)

Example warning:

```
macios/runtime/trampolines.m:1784:9: error: cast from 'void *(*)(MonoObject *, void *, GCHandle *)' (aka 'void *(*)(_MonoObject *, void *, void **)') to 'xamarin_managed_to_id_func' (aka 'id (*)(_MonoObject *, void *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
 1784 |         return (xamarin_managed_to_id_func) xamarin_smart_enum_to_nsstring;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
…-body

Example warning:

```
macios/runtime/shared.m:50:106: error: semicolon before method body is ignored [-Werror,-Wsemicolon-before-method-body]
   50 | -(id) initWithData: (void *) targ selector:(SEL) sel argument:(id) arg is_direct_binding:(bool) is_direct;
      |                                                                                                          ^
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
Example warning:

```
macios/runtime/trampolines-arm64.m:214:21: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
  214 |                 for (int i = 1; i < struct_length; i++)
      |                                 ~ ^ ~~~~~~~~~~~~~
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
Example warning:

```
macios/runtime/trampolines-invoke.m:212:15: error: declaration shadows a local variable [-Werror,-Wshadow]
  212 |                 const char *type = xamarin_skip_encoding_flags (argType);
      |                             ^
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
Example warning:

```objc
nsstring-localization.m:33:46: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
   33 |         return [NSString localizedStringWithFormat: format, a];
      |                                                     ^~~~~~
```

References:

* https://developer.apple.com/documentation/xcode/enabling-enhanced-security-for-your-app
* https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features (for -ftrivial-auto-var-init=zero)

Contributes towards #23023.
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne changed the base branch from dev/rolf/safer-flags-Wformat-nonliteral to main October 28, 2025 12:33
@rolfbjarne rolfbjarne enabled auto-merge (squash) October 28, 2025 12:34
@rolfbjarne rolfbjarne linked an issue Oct 28, 2025 that may be closed by this pull request
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #d29cb35] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build #d29cb35] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

💻 [CI Build #d29cb35] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

💻 [CI Build #d29cb35] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

💻 [CI Build #d29cb35] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

💻 [CI Build #d29cb35] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

💻 [CI Build #d29cb35] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: d29cb353994e36634969d031253810bf89cb120a [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

@rolfbjarne rolfbjarne merged commit 0d596a4 into main Oct 28, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Look into new security features with Xcode 26

3 participants