Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8019 from WalterBright/fix18597
fix Issue 18597 - more unsafe unaligned pointer errors merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* TEST_OUTPUT: | ||
--- | ||
fail_compilation/test18597.d(24): Error: field `Unaligned.p` cannot modify misaligned pointers in `@safe` code | ||
fail_compilation/test18597.d(25): Error: field `Unaligned.p` cannot assign to misaligned pointers in `@safe` code | ||
fail_compilation/test18597.d(26): Error: field `Unaligned.p` cannot assign to misaligned pointers in `@safe` code | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=18597 | ||
|
||
@safe: | ||
|
||
align(1) | ||
struct Unaligned | ||
{ | ||
align(1): | ||
ubyte filler; | ||
int* p; | ||
} | ||
|
||
void test() | ||
{ | ||
Unaligned u; | ||
u.p = new int; | ||
Unaligned v = Unaligned(0, new int); | ||
Unaligned w = { p : new int }; | ||
} |