Re: betterC and noboundscheck

2017-11-24 Thread Michael V. Franklin via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: import core.stdc.stdio; import std.algorithm : min; extern (C) void main() { char[256] buf; buf[] = '\0'; auto str = "hello world"; auto ln = min(buf.length, str.length); buf[0..ln] = str[0..ln];

Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn
On Friday, 24 November 2017 at 05:01:17 UTC, Basile B. wrote: On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include'

Re: betterC and noboundscheck

2017-11-23 Thread Basile B. via Digitalmars-d-learn
On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include' -noboundscheck flag? It's bug or in some cases it's useful?

Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include' -noboundscheck flag? It's bug or in some cases it's useful? Interestingly, ldc2 will compile this ok, without the -noboundscheck

Re: betterC and noboundscheck

2017-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 16:57:10 UTC, Joakim wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: [...] betterC is a new feature that's still being worked on and still has holes in it: https://github.com/dlang/dmd/pull/7151 I suggest you open an issue for it on

Re: betterC and noboundscheck

2017-11-22 Thread Joakim via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: Hello. I try compile simple example: import core.stdc.stdio; import std.algorithm : min; extern (C) void main() { char[256] buf; buf[] = '\0'; auto str = "hello world"; auto ln = min(buf.length, str.length);

Re: betterC and noboundscheck

2017-11-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: Why -betterC flag not 'include' -noboundscheck flag? -noboundscheck is extremely harmful. If -betterC implied that, it would no longer be a better C, it would just be the same buggy C. The compiler should perhaps inline the

betterC and noboundscheck

2017-11-22 Thread Oleg B via Digitalmars-d-learn
Hello. I try compile simple example: import core.stdc.stdio; import std.algorithm : min; extern (C) void main() { char[256] buf; buf[] = '\0'; auto str = "hello world"; auto ln = min(buf.length, str.length); buf[0..ln] = str[0..ln]; printf("%s\n", buf.ptr); } rdmd