digitalmars.D.learn - betterC and noboundscheck
- Oleg B (25/25) Nov 22 2017 Hello. I try compile simple example:
- Adam D. Ruppe (5/6) Nov 22 2017 -noboundscheck is extremely harmful. If -betterC implied that, it
- Joakim (8/33) Nov 22 2017 betterC is a new feature that's still being worked on and still
- Nicholas Wilson (3/12) Nov 22 2017 see also https://github.com/ldc-developers/ldc/pull/2426 (also
- codephantom (6/10) Nov 23 2017 Interestingly, ldc2 will compile this ok, without the
- Basile B. (4/16) Nov 23 2017 It's b/c LDC2 doesn't have the most recent betterC features. It
- codephantom (5/25) Nov 23 2017 Thanks. I didn't take that into account (was using LDC 1.5.0
- Michael V. Franklin (2/20) Nov 24 2017 Bug submitted here: https://issues.dlang.org/show_bug.cgi?id=18010
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 -betterC bettercarray2.d and get error: /tmp/.rdmd-1000/rdmd-bettercarray2.d-435C14EC3DAF09FFABF8ED6919B624C1/o js/bettercarray2.o: In function `main': bettercarray2.d:(.text.main[main]+0xbc): undefined reference to `_d_arraycopy' collect2: error: ld returned 1 exit status Error: linker exited with status 1 If I understand correctly _d_arraycopy is part of druntime and it check bounds of array access. 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?
Nov 22 2017
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 bounds check so it doesn't need the druntime function, but it certainly shouldn't skip it.
Nov 22 2017
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); buf[0..ln] = str[0..ln]; printf("%s\n", buf.ptr); } rdmd -betterC bettercarray2.d and get error: /tmp/.rdmd-1000/rdmd-bettercarray2.d-435C14EC3DAF09FFABF8ED6919B624C1/o js/bettercarray2.o: In function `main': bettercarray2.d:(.text.main[main]+0xbc): undefined reference to `_d_arraycopy' collect2: error: ld returned 1 exit status Error: linker exited with status 1 If I understand correctly _d_arraycopy is part of druntime and it check bounds of array access. 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?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 bugzilla, as this sounds like either a hole or at least something that should be documented better: https://issues.dlang.org
Nov 22 2017
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:see also https://github.com/ldc-developers/ldc/pull/2426 (also WiP).[...]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 bugzilla, as this sounds like either a hole or at least something that should be documented better: https://issues.dlang.org
Nov 22 2017
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 flag btw. you should start using: boundscheck=off/on/safeonly flag instead i believe. https://dlang.org/dmd-windows.html#switch-boundscheck
Nov 23 2017
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:It's b/c LDC2 doesn't have the most recent betterC features. It works just like it worked in older DMD release (e.g w 2.075), when betterC was "inexact" / "mostly unimplemented"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 flag btw. you should start using: boundscheck=off/on/safeonly flag instead i believe. https://dlang.org/dmd-windows.html#switch-boundscheck
Nov 23 2017
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:Thanks. I didn't take that into account (was using LDC 1.5.0 ..based on 2.075.1) Getting used to monthly compiler updates is a real challenge.. not something I'm used to ;-)On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:It's b/c LDC2 doesn't have the most recent betterC features. It works just like it worked in older DMD release (e.g w 2.075), when betterC was "inexact" / "mostly unimplemented"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 flag btw. you should start using: boundscheck=off/on/safeonly flag instead i believe. https://dlang.org/dmd-windows.html#switch-boundscheck
Nov 23 2017
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]; printf("%s\n", buf.ptr); } rdmd -betterC bettercarray2.d and get error: /tmp/.rdmd-1000/rdmd-bettercarray2.d-435C14EC3DAF09FFABF8ED6919B624C1/o js/bettercarray2.o: In function `main': bettercarray2.d:(.text.main[main]+0xbc): undefined reference to `_d_arraycopy' collect2: error: ld returned 1 exit status Error: linker exited with status 1Bug submitted here: https://issues.dlang.org/show_bug.cgi?id=18010
Nov 24 2017