[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 Iain Buclaw changed: What|Removed |Added Priority|P1 |P2 --

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-02-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #16 from Paul Backus --- (In reply to Steven Schveighoffer from comment #15) > > The whole point of @safe is to avoid code review. Otherwise it's a > glamorized linter. If you have to review @safe code to make sure things > outside the s

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-02-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 anonymous4 changed: What|Removed |Added Blocks||19916 See Also|https://issues.dlang.o

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-02-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 anonymous4 changed: What|Removed |Added See Also||https://issues.dlang.org/sh |

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #15 from Steven Schveighoffer --- (In reply to Paul Backus from comment #14) > (In reply to Steven Schveighoffer from comment #12) > > > > On the grounds that it's not desirable. It does not cause undefined > > behavior, just useless beh

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #14 from Paul Backus --- (In reply to Steven Schveighoffer from comment #12) > > On the grounds that it's not desirable. It does not cause undefined > behavior, just useless behavior. We are better off disallowing it. "I don't like it"

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #13 from Steven Schveighoffer --- (In reply to Steven Schveighoffer from comment #12) > It's just that the rules leave us with the reality that using such unions > usable in @safe or @trusted code has no utility. I rewrote this several

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #12 from Steven Schveighoffer --- (In reply to Paul Backus from comment #11) > > Read-only access is fine. Write access is not. > > Again, on what grounds do you make this claim? Can writing to the integer > member cause undefined behavi

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #11 from Paul Backus --- > Read-only access is fine. Write access is not. Again, on what grounds do you make this claim? Can writing to the integer member cause undefined behavior in @safe-only code? If so, please provide an example. >

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #10 from Steven Schveighoffer --- (In reply to Paul Backus from comment #9) > > I'm disagreeing with the ability of safe code to access any part of this. > > On what grounds? The point of @safe is to prevent undefined behavior, and > all

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #9 from Paul Backus --- > I'm disagreeing with the ability of safe code to access any part of this. On what grounds? The point of @safe is to prevent undefined behavior, and allowing access to the integer cannot possibly lead to undefine

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #8 from Steven Schveighoffer --- (In reply to RazvanN from comment #5) > (In reply to Steven Schveighoffer from comment #3) > > If you do intend to access the int *, then having any safe code anywhere > > just change the integer ruins the

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #7 from Steven Schveighoffer --- (In reply to Paul Backus from comment #4) > The *intent* of the spec is clearly to allow code like this to be marked as > @trusted. If the current wording of the spec does not allow that, then the > spec's

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #6 from ag0aep6g --- (In reply to Paul Backus from comment #2) > The question is: should the value of `t` after `t.x = 5`, in comment 1's > example, be considered an unsafe value? [...] > If we amend the spec as follows: > > > A struct/u

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 RazvanN changed: What|Removed |Added CC||razvan.nitu1...@gmail.com --- Comment #5 from Razv

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #4 from Paul Backus --- Consider the following example: --- union T { int x; int* y; } @trusted void example(T t) { import std.stdio; t.x = 123; writeln(t.x); t.y = new int; writeln(t.y); } --- This code is memory-

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 --- Comment #3 from Steven Schveighoffer --- A union between a pointer and integer is most definitely unsafe in all instances. If you never intend to access the int*, in any circumstance, then why have a union? If you do intend to access the int *,

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 Paul Backus changed: What|Removed |Added CC||snarwin+bugzi...@gmail.com --- Comment #2 from

[Issue 21565] @safe code allows modification of a scalar that overlaps with a pointer

2021-01-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=21565 ag0aep6g changed: What|Removed |Added CC||ag0ae...@gmail.com --- Comment #1 from ag0aep6g