Clarify rules on safety and sizeof#1721
Conversation
This is a small focused change, but fixes what I (at least) misinterpreted at least twice. In version 7.3 we correctly updated the rules for in 8.8 for Unmanaged types to include struct types where the fields are all unmanaged types. This includes generic types where the type parameter has the `unmanaged` constraint. However, we didn't restate the restrictions for `sizeof` in 12.8.19 to prevent extending the allowed types in safe context to include those types. I updated the language in 12.8.19 to make those restrictions clear.
Nigel-Ecma
left a comment
There was a problem hiding this comment.
LGTM
§24.6.9 is as undefined as ever, but that is by design.
|
Adding as a comment here so we can discuss it... 24.6.9 starts with:
It's not clear from that sentence that sizeof yields a constant int value for enums. Should we update that as well? (I'm happy to create a PR for that.) Separately, 24.6.9 doesn't have a restriction on sizeof only being used for unmanaged types, so there's nothing to stop |
|
Bill will remove "predefined" from the first sentence in 24.6.9 and add the line break as suggested, then we can merge. |
We made a few smaller tweaks to the fix here.
This is a small focused change, but fixes what I (at least) misinterpreted at least twice.
In version 7.3 we correctly updated the rules for in 8.8 for Unmanaged types to include struct types where the fields are all unmanaged types. This includes generic types where the type parameter has the
unmanagedconstraint.However, we didn't restate the restrictions for
sizeofin 12.8.19 to prevent extending the allowed types in safe context to include those types.I updated the language in 12.8.19 to make those restrictions clear.