digitalmars.D.learn - A strange DMD error
- Keivan Shah (45/45) Nov 01 2022 Hello,
- Imperatorn (4/10) Nov 01 2022 Could be there's some restriction in DMD on number of arguments.
- Keivan Shah (8/20) Nov 01 2022 Possible, but I think I have had code with more arguments than
- Imperatorn (4/20) Nov 01 2022 Hehe.
- Keivan Shah (7/10) Nov 01 2022 Yeah, can do, thanks for the suggestion. But anyways still want
- Tejas (5/28) Nov 01 2022 Regarding the too many configurable parameters, the general
- Steven Schveighoffer (10/56) Nov 01 2022 100% this is a bug in DMD. It should be filed.
- Keivan Shah (4/13) Nov 02 2022 Hey, have already filled an issue:
- ryuukk_ (2/2) Nov 01 2022 This reminds me of an issue i reported last year...
- Keivan Shah (6/8) Nov 02 2022 This seems to be very similar to the bug I am facing, mostly the
Hello, Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code ```D import std; alias DG = void delegate(); class TType { } class MyClass { this(TType t1, TType, double, double[2], double, double, DG, TType, TType, DG, DG, DG, double, double, double, double, double, ulong, bool) { assert(t1 is null); // I am passing null so should be null! // NOTE: Seems to work in LDC but fails in DMD. writeln("No Bug!"); } } void main() { auto tt = new TType; new MyClass(null, tt, 0, [0, 0], 0, 0, null, null, null, null, null, null, 0, 0, 0, 0, 0, 0, false); } ``` The code gives an assertion failure on the current versions of dmd (reproducible on [run.dlang.io](https://run.dlang.io) as well) and does not happen when using LDC. The bug seems to be sensitive to the number of arguments and their types making it reproducible only in very limited cases. I have tried my best to reduce it to minimum but still does require these many arguments. The end results seems to me like variables are shifted i.e. variable 1 gets value of variable 2 and so on, but don't have enough proof to support this. I just wanted some help on the best way to avoid this bug in my code and maybe some clue on what causes the error in the first place and how should I go about reporting this. Keivan
Nov 01 2022
On Tuesday, 1 November 2022 at 15:40:04 UTC, Keivan Shah wrote:Hello, Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code [...]Could be there's some restriction in DMD on number of arguments. May I ask if this was just an experiment? I hope you're not having code like that in the wild 🙏
Nov 01 2022
On Tuesday, 1 November 2022 at 15:42:43 UTC, Imperatorn wrote:On Tuesday, 1 November 2022 at 15:40:04 UTC, Keivan Shah wrote:Possible, but I think I have had code with more arguments than this and it has worked 😅 Unfortunately, not an experiment. Although have replaced the types so seems silly now, this is part of my constructor for a huge co-coordinator class that takes too many configurable start time parameters and so need to pass these many arguments. KeivanHello, Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code [...]Could be there's some restriction in DMD on number of arguments. May I ask if this was just an experiment? I hope you're not having code like that in the wild 🙏
Nov 01 2022
On Tuesday, 1 November 2022 at 15:49:54 UTC, Keivan Shah wrote:On Tuesday, 1 November 2022 at 15:42:43 UTC, Imperatorn wrote:Hehe. One simple thing you could do is to create a struct instead for you params and pass thatOn Tuesday, 1 November 2022 at 15:40:04 UTC, Keivan Shah wrote:Possible, but I think I have had code with more arguments than this and it has worked 😅 Unfortunately, not an experiment. Although have replaced the types so seems silly now, this is part of my constructor for a huge co-coordinator class that takes too many configurable start time parameters and so need to pass these many arguments. Keivan[...]Could be there's some restriction in DMD on number of arguments. May I ask if this was just an experiment? I hope you're not having code like that in the wild 🙏
Nov 01 2022
On Tuesday, 1 November 2022 at 16:06:44 UTC, Imperatorn wrote:Hehe. One simple thing you could do is to create a struct instead for you params and pass thatYeah, can do, thanks for the suggestion. But anyways still want to see if anyone else has seen this issue, or has a clue about what could be happening here. Seems like a rare issue and took up too much of my time so better if it's solved or at least documented somewhere in the meantime. I have filed an issue for this now: https://issues.dlang.org/show_bug.cgi?id=23450
Nov 01 2022
On Tuesday, 1 November 2022 at 15:49:54 UTC, Keivan Shah wrote:On Tuesday, 1 November 2022 at 15:42:43 UTC, Imperatorn wrote:Regarding the too many configurable parameters, the general advice is to group all of the params into a `struct` and pass that instead as argument to constructor Pretty wild bug though, definitely a backend thingOn Tuesday, 1 November 2022 at 15:40:04 UTC, Keivan Shah wrote:Possible, but I think I have had code with more arguments than this and it has worked 😅 Unfortunately, not an experiment. Although have replaced the types so seems silly now, this is part of my constructor for a huge co-coordinator class that takes too many configurable start time parameters and so need to pass these many arguments. KeivanHello, Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code [...]Could be there's some restriction in DMD on number of arguments. May I ask if this was just an experiment? I hope you're not having code like that in the wild 🙏
Nov 01 2022
On 11/1/22 11:40 AM, Keivan Shah wrote:Hello, Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code ```D import std; alias DG = void delegate(); class TType { } class MyClass { this(TType t1, TType, double, double[2], double, double, DG, TType, TType, DG, DG, DG, double, double, double, double, double, ulong, bool) { assert(t1 is null); // I am passing null so should be null! // NOTE: Seems to work in LDC but fails in DMD. writeln("No Bug!"); } } void main() { auto tt = new TType; new MyClass(null, tt, 0, [0, 0], 0, 0, null, null, null, null, null, null, 0, 0, 0, 0, 0, 0, false); } ``` The code gives an assertion failure on the current versions of dmd (reproducible on [run.dlang.io](https://run.dlang.io) as well) and does not happen when using LDC. The bug seems to be sensitive to the number of arguments and their types making it reproducible only in very limited cases. I have tried my best to reduce it to minimum but still does require these many arguments. The end results seems to me like variables are shifted i.e. variable 1 gets value of variable 2 and so on, but don't have enough proof to support this.100% this is a bug in DMD. It should be filed. I ran some more tests, removing almost any of the parameters or changing their types seems to avoid the problem. I also added a parameter name for the second parameter, and DMD appears to be in this case passing the parameters in the wrong order (t1 is actually tt, t2 is null) You can also remove the `import std`, just the assert is enough. Please file if you can: https://issues.dlang.org -Steve
Nov 01 2022
On Tuesday, 1 November 2022 at 16:39:57 UTC, Steven Schveighoffer wrote:100% this is a bug in DMD. It should be filed. I ran some more tests, removing almost any of the parameters or changing their types seems to avoid the problem. I also added a parameter name for the second parameter, and DMD appears to be in this case passing the parameters in the wrong order (t1 is actually tt, t2 is null) You can also remove the `import std`, just the assert is enough. Please file if you can: https://issues.dlang.org -SteveHey, have already filled an issue: https://issues.dlang.org/show_bug.cgi?id=23450)
Nov 02 2022
This reminds me of an issue i reported last year... https://issues.dlang.org/show_bug.cgi?id=22583
Nov 01 2022
On Tuesday, 1 November 2022 at 17:05:03 UTC, ryuukk_ wrote:This reminds me of an issue i reported last year... https://issues.dlang.org/show_bug.cgi?id=22583This seems to be very similar to the bug I am facing, mostly the same underlying issue. Should we somehow link the 2 issues and escalate? Link to my issue: https://issues.dlang.org/show_bug.cgi?id=23450)
Nov 02 2022