digitalmars.D.learn - Linker error
- Anonymous (26/26) Jun 05 2016 Why does the following give a linker error?
- Anonymous (8/34) Jun 05 2016 Should have included:
- docandrew (4/13) Jun 05 2016 Hmm, on OSX w/ dmd v2.071.0 I'm unable to duplicate. Can you try
- Anonymous (12/27) Jun 05 2016 I upgraded, but I still get the same error:
- Andrej Mitrovic via Digitalmars-d-learn (11/17) Jun 05 2016 It's likely an accepts-invalid bug, meaning it should be a compiler
- Anonymous (8/26) Jun 05 2016 Should I report this as a dmd bug then? Not sure where / how to
- Andrej Mitrovic via Digitalmars-d-learn (5/12) Jun 05 2016 You can report it here: https://issues.dlang.org
Why does the following give a linker error? If I change static Note[0] empty; to static Note[] empty;, all is well. Or if I leave it as Note[0] empty; and don't use it in getNotes, all is well. struct Note { string topic; string content; } class NoteStore { Note[][string] store; static Note[0] empty; Note[] getNotes(string id) { return (id in store) ? store[id] : empty; } } void main() {} dmd --version DMD32 D Compiler v2.070.0 Windows 10
Jun 05 2016
On Sunday, 5 June 2016 at 18:30:25 UTC, Anonymous wrote:Why does the following give a linker error? If I change static Note[0] empty; to static Note[] empty;, all is well. Or if I leave it as Note[0] empty; and don't use it in getNotes, all is well. struct Note { string topic; string content; } class NoteStore { Note[][string] store; static Note[0] empty; Note[] getNotes(string id) { return (id in store) ? store[id] : empty; } } void main() {} dmd --version DMD32 D Compiler v2.070.0 Windows 10Should have included: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html ns.obj(ns) Offset 0BA0AH Record Type 009D Error 16: Index Range --- errorlevel 1
Jun 05 2016
On Sunday, 5 June 2016 at 18:36:13 UTC, Anonymous wrote:On Sunday, 5 June 2016 at 18:30:25 UTC, Anonymous wrote:Hmm, on OSX w/ dmd v2.071.0 I'm unable to duplicate. Can you try upgrading to v2.071 and see if that works? -Jon[...]Should have included: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html ns.obj(ns) Offset 0BA0AH Record Type 009D Error 16: Index Range --- errorlevel 1
Jun 05 2016
On Sunday, 5 June 2016 at 18:45:36 UTC, docandrew wrote:On Sunday, 5 June 2016 at 18:36:13 UTC, Anonymous wrote:I upgraded, but I still get the same error: dmd ns.d OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html ns.obj(ns) Offset 00678H Record Type 009D Error 16: Index Range --- errorlevel 1 dmd --version DMD32 D Compiler v2.071.0 Copyright (c) 1999-2015 by Digital Mars written by Walter BrightOn Sunday, 5 June 2016 at 18:30:25 UTC, Anonymous wrote:Hmm, on OSX w/ dmd v2.071.0 I'm unable to duplicate. Can you try upgrading to v2.071 and see if that works? -Jon[...]Should have included: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html ns.obj(ns) Offset 0BA0AH Record Type 009D Error 16: Index Range --- errorlevel 1
Jun 05 2016
On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:static Note[0] empty; Note[] getNotes(string id) { return (id in store) ? store[id] : empty; }It's likely an accepts-invalid bug, meaning it should be a compiler error instead. I don't think it makes sense that the compiler tries to slice a fixed-length array of length zero.. tho perhaps it should just equate that to returning null. In any case you can return `null` instead of "empty". Fixed-length arrays of length zero aren't really all that well-defined. Some would say they make no sense, but there is a weird benefit to them when used with the built-in hashmaps (a void[0] value type wouldn't allocate memory, AFAIR and if that is still true).
Jun 05 2016
On Sunday, 5 June 2016 at 20:16:54 UTC, Andrej Mitrovic wrote:On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Should I report this as a dmd bug then? Not sure where / how to do that. I think I'll just let it go; I was able to work passed it anyway using "static Note[] empty;", and `null` works too. Is either one better? By the way, this is from an example I found in "D Web Development" by Kai Nacke.static Note[0] empty; Note[] getNotes(string id) { return (id in store) ? store[id] : empty; }It's likely an accepts-invalid bug, meaning it should be a compiler error instead. I don't think it makes sense that the compiler tries to slice a fixed-length array of length zero.. tho perhaps it should just equate that to returning null. In any case you can return `null` instead of "empty". Fixed-length arrays of length zero aren't really all that well-defined. Some would say they make no sense, but there is a weird benefit to them when used with the built-in hashmaps (a void[0] value type wouldn't allocate memory, AFAIR and if that is still true).
Jun 05 2016
On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Should I report this as a dmd bug then? Not sure where / how to do that.You can report it here: https://issues.dlang.orgI think I'll just let it go; I was able to work passed it anyway using "static Note[] empty;", and `null` works too. Is either one better?null is simpler from a reader's perspective. :)By the way, this is from an example I found in "D Web Development" by Kai Nacke.Interesting that they would use such code in the book. Which chapter is it?
Jun 05 2016
On Sunday, 5 June 2016 at 21:16:36 UTC, Andrej Mitrovic wrote:On 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks. I agree it's simpler and switched to `null`. The example is in chapter 3.Should I report this as a dmd bug then? Not sure where / how to do that.You can report it here: https://issues.dlang.orgI think I'll just let it go; I was able to work passed it anyway using "static Note[] empty;", and `null` works too. Is either one better?null is simpler from a reader's perspective. :)By the way, this is from an example I found in "D Web Development" by Kai Nacke.Interesting that they would use such code in the book. Which chapter is it?
Jun 05 2016
On Sunday, 5 June 2016 at 21:26:56 UTC, Anonymous wrote:On Sunday, 5 June 2016 at 21:16:36 UTC, Andrej Mitrovic wrote:That it works on OSX but not on Windows makes me think it should definitely be reported as a bug. -JonOn 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks. I agree it's simpler and switched to `null`. The example is in chapter 3.Should I report this as a dmd bug then? Not sure where / how to do that.You can report it here: https://issues.dlang.orgI think I'll just let it go; I was able to work passed it anyway using "static Note[] empty;", and `null` works too. Is either one better?null is simpler from a reader's perspective. :)By the way, this is from an example I found in "D Web Development" by Kai Nacke.Interesting that they would use such code in the book. Which chapter is it?
Jun 05 2016
On Monday, 6 June 2016 at 02:21:03 UTC, docandrew wrote:On Sunday, 5 June 2016 at 21:26:56 UTC, Anonymous wrote:https://issues.dlang.org/show_bug.cgi?id=16129On Sunday, 5 June 2016 at 21:16:36 UTC, Andrej Mitrovic wrote:That it works on OSX but not on Windows makes me think it should definitely be reported as a bug. -JonOn 6/5/16, Anonymous via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks. I agree it's simpler and switched to `null`. The example is in chapter 3.[...]You can report it here: https://issues.dlang.org[...]null is simpler from a reader's perspective. :)[...]Interesting that they would use such code in the book. Which chapter is it?
Jun 05 2016