swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.67k stars 10.38k forks source link

[SR-9336] importing structures with anonymous fields crashes the ClangImporter #51806

Open compnerd opened 6 years ago

compnerd commented 6 years ago
Previous ID SR-9336
Radar None
Original Reporter @compnerd
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Improvement, Android, ClangImporter, Linux, StarterBug, Windows | |Assignee | None | |Priority | Medium | md5: e340d6800850b57905470aa79f4a8815

Issue Description:

Seems that the typo correction on windows asserts trying to create an anonymous field accessor. This occurred at least in Data.swift in swift-corelibs-foundation trying to typo correct munmap.

belkadan commented 6 years ago

I bet this reproduces on other platforms if you can figure out what it was trying to import.

compnerd commented 5 years ago

This is due to the use of anonymous fields in structures which Microsoft uses extensively in the Windows SDK. Something like this does the trick:

```
import WinSDK
_ = htont()
```