Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread ag0aep6g via Digitalmars-d
On 01/23/2018 03:38 AM, Mike Franklin wrote: import std.stdio; void main() @safe {     string foo = "foo";     string* ls0;     string* p1, p2;     ls0 = &foo;     p1 = ls0;     ls0.destroy();     p2 = ls0;     writeln(p2.length); } Compile with `-dip1000` Error: program killed by sig

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Tuesday, 23 January 2018 at 02:25:57 UTC, Mike Franklin wrote: Should `destroy` be `@system` so it can't be called in `@safe` code, or should the compiler be smart enough to figure out the flow control and throw an error? Interestingly, `destroy` is an unsafe operation for classes. import

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Tuesday, 23 January 2018 at 02:38:42 UTC, Mike Franklin wrote: So that's bad. But it looks like a bug in `-dip1000` https://issues.dlang.org/show_bug.cgi?id=18283

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Nicholas Wilson via Digitalmars-d
On Tuesday, 23 January 2018 at 02:25:57 UTC, Mike Franklin wrote: Not sure how to precisely define the problem here. Should `destroy` be `@system` so it can't be called in `@safe` code, or should the compiler be smart enough to figure out the flow control and throw an error? Mike The compi

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Tuesday, 23 January 2018 at 02:25:57 UTC, Mike Franklin wrote: Due to the aforementioned bugs in my prior posts, I couldn't even make an example to demonstrate in @safe code, so I modified the example slightly in an effort to reproduce the same problem. import std.stdio; void main() @saf

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Tuesday, 23 January 2018 at 01:08:19 UTC, ag0aep6g wrote: The real question is about this line: p2 = ls[0]; That's an out-of-bounds access, and the compiler does not catch this statically. Instead, it inserts bounds-checking code that crashes the program safely with an `Error`. Due

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Tuesday, 23 January 2018 at 01:08:19 UTC, ag0aep6g wrote: The real question is about this line: p2 = ls[0]; That's an out-of-bounds access, and the compiler does not catch this statically. Instead, it inserts bounds-checking code that crashes the program safely with an `Error`. In t

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Tuesday, 23 January 2018 at 01:08:19 UTC, ag0aep6g wrote: If you add `@safe`, the compiler rejects this line: ls ~= &foo; But that line would only be problematic if the pointer would leave the scope of the function. It doesn't, so this is actually safe. But the compiler isn't smart en

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread ag0aep6g via Digitalmars-d
On 01/23/2018 01:20 AM, Mike Franklin wrote: I would be surprised if the compiler allowed you to do something like this in `@safe` code. You might get surprised then, if you expect the compiler to reject code like that statically. If you add `@safe`, the compiler rejects this line: ls ~

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Seb via Digitalmars-d
On Tuesday, 23 January 2018 at 00:20:45 UTC, Mike Franklin wrote: On Monday, 22 January 2018 at 23:30:16 UTC, Aedt wrote: [...] D is not memory safe by default (unfortunately), so it's not surprising to me that you can do this in `@system` code. I would be surprised if the compiler allowed

Re: Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Mike Franklin via Digitalmars-d
On Monday, 22 January 2018 at 23:30:16 UTC, Aedt wrote: I was asked in Reddit (https://www.reddit.com/r/learnprogramming/comments/7ru82l/i_was_thinking_of_using_d_haxe_or_another/) how would D handle the following similar D code. I'm surprised that both dmd and ldc provides no warnings even with

Shouldn't invalid references like this fail at compile time?

2018-01-22 Thread Aedt via Digitalmars-d
I was asked in Reddit (https://www.reddit.com/r/learnprogramming/comments/7ru82l/i_was_thinking_of_using_d_haxe_or_another/) how would D handle the following similar D code. I'm surprised that both dmd and ldc provides no warnings even with -w argument passed. import std.stdio; void main() {

Re: gRPC in D good idea for GSOC 2018?

2018-01-22 Thread Adrian Matoga via Digitalmars-d
On Monday, 15 January 2018 at 19:28:08 UTC, Ali Çehreli wrote: I know a project where D could benefit from gRPC in D, which is not among the supported languages: https://grpc.io/docs/ Do you think gRPC support is worth adding to GSOC 2018 ideas? https://wiki.dlang.org/GSOC_2018_Ideas Ali

Re: gRPC in D good idea for GSOC 2018?

2018-01-22 Thread Andrew Benton via Digitalmars-d
On Monday, 22 January 2018 at 05:54:31 UTC, Dmitry Olshansky wrote: On Monday, 22 January 2018 at 04:40:53 UTC, Andrew Benton wrote: On Monday, 15 January 2018 at 19:28:08 UTC, Ali Çehreli wrote: I know a project where D could benefit from gRPC in D, which is not among the supported languages:

Re: Some Observations on the D Development Process

2018-01-22 Thread Chris via Digitalmars-d
On Friday, 5 January 2018 at 03:28:10 UTC, Walter Bright wrote: There's a lot of technical debt I've been trying to fix with that, and nobody else seems willing to do it. For example, fixing the error messages so they make use of color syntax highlighting. It's boring, tedious, unfun work, mea