Re: Problem with Exceptions in Constructor

2021-06-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 11 June 2021 at 20:09:22 UTC, Mike Brown wrote: The error is flagged on the writeln(e.msg). Do I need to do something special to pass a string to an exception? dup? No, that code is fine. You're passing a string literal, so there's no need for a dup.

Re: Unittests not firing?

2021-06-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 11, 2021 at 02:05:31PM -0700, H. S. Teoh wrote: [...] > Huh, that doesn't look right. This was fixed since June last year, so it > *should* have made it into the latest compiler releases already. Unless > this one was missed somehow (but I doubt it). [...] Just checked on LDC 1.26.0,

Re: Unittests not firing?

2021-06-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 11, 2021 at 08:30:28PM +, Mike Brown via Digitalmars-d-learn wrote: > On Friday, 11 June 2021 at 16:28:48 UTC, H. S. Teoh wrote: > > On Fri, Jun 11, 2021 at 03:20:49PM +, Mike Brown via > > Digitalmars-d-learn wrote: > > > On Friday, 11 June 2021 at 15:13:17 UTC, rikki

Re: Unittests not firing?

2021-06-11 Thread Mike Brown via Digitalmars-d-learn
On Friday, 11 June 2021 at 16:28:48 UTC, H. S. Teoh wrote: On Fri, Jun 11, 2021 at 03:20:49PM +, Mike Brown via Digitalmars-d-learn wrote: On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote: [...] Right OK, mine says 1/1 unittests failed - but this should say Modules? I

Problem with Exceptions in Constructor

2021-06-11 Thread Mike Brown via Digitalmars-d-learn
Hi all, AddressSanitizer is throwing an access-violation error - I've managed to boil it down to this example: ```d import std.stdio; class example: Exception { this(string msg, string file = __FILE__, size_t line = __LINE__) { super(msg, file, line); } } class

Re: Two interpretations

2021-06-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 11, 2021 at 03:00:00PM +, JG via Digitalmars-d-learn wrote: > Is it specified somewhere which way the following program will be > interpreted? > > import std; > > struct A > { > int x=17; > } > > int x(A a) > { > return 100*a.x; > } >

Re: Unittests not firing?

2021-06-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 11, 2021 at 03:20:49PM +, Mike Brown via Digitalmars-d-learn wrote: > On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote: [...] > Right OK, mine says 1/1 unittests failed - but this should say > Modules? > > I will interpret it as Modules, ty! This is a bug that was

Re: Unittests not firing?

2021-06-11 Thread Mike Brown via Digitalmars-d-learn
On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote: rdmd -main -unittest file.d ```d import std.stdio; unittest { writeln("first"); } unittest { writeln("second"); assert(0); } ``` Output: ``` first second onlineapp.d(11): [unittest] unittest failure 1/1 modules

Re: Unittests not firing?

2021-06-11 Thread rikki cattermole via Digitalmars-d-learn
rdmd -main -unittest file.d ```d import std.stdio; unittest { writeln("first"); } unittest { writeln("second"); assert(0); } ``` Output: ``` first second onlineapp.d(11): [unittest] unittest failure 1/1 modules FAILED unittests ``` The first assert to execute should kill the

Two interpretations

2021-06-11 Thread JG via Digitalmars-d-learn
Is it specified somewhere which way the following program will be interpreted? import std; struct A { int x=17; } int x(A a) { return 100*a.x; } void main() { A a; writeln(a.x); }

Unittests not firing?

2021-06-11 Thread Mike Brown via Digitalmars-d-learn
Hi all, I'm testing the unittest features of D, and having some issues. I only seem able to fire one unittest, e.g. module test; unittest { assert(0); } unittest { assert(0); } If I run, rdmd -g -unittest -main "test.d" It returns, 1/1 unittests FAILED

Creating a static library

2021-06-11 Thread Mike Brown via Digitalmars-d-learn
Hi all, My goal is to modularise my code better. I think I'd like to make a static library, this will primarily to be used in other D projects. https://dlang.org/articles/dll-linux.html mentions the GC and linking requirements. I am happy to not use the GC for this library, what is the

Re: difficulty with rectangular arrays

2021-06-11 Thread Dennis via Digitalmars-d-learn
On Friday, 11 June 2021 at 08:30:29 UTC, Moth wrote: what's going on? It's a bug: [Issue 19178 - Static initialization of 2d static arrays in structs produces garbage or doesn't compile sometimes](https://issues.dlang.org/show_bug.cgi?id=19178)

Re: difficulty with rectangular arrays

2021-06-11 Thread Moth via Digitalmars-d-learn
On Friday, 11 June 2021 at 08:40:51 UTC, jfondren wrote: The example in the spec is in a function body and you've copied it to a class body, where the writeln() would also be in error. I find https://dlang.org/spec/grammar.html quite hard to read but I imagine there's a state/declaration

Re: difficulty with rectangular arrays

2021-06-11 Thread jfondren via Digitalmars-d-learn
On Friday, 11 June 2021 at 08:30:29 UTC, Moth wrote: ``` class ExampleClass { double[6][3] matrix = 0; //fails to compile - "Error: cannot implicitly convert expression `0` of type `int` to `double[6][3]`" } ``` evidently i'm doing something wrong here, but i can't understand what or

Re: Cast class reference to pointer of another class?

2021-06-11 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 10 June 2021 at 23:47:33 UTC, Paul Backus wrote: On Thursday, 10 June 2021 at 21:25:35 UTC, JN wrote: I have to disagree. I don't see a good reason for this behavior and it's just one more thing to trip people. I think it'd be better if such thing was done explicit, something

difficulty with rectangular arrays

2021-06-11 Thread Moth via Digitalmars-d-learn
hullo all. i've encountered a bizzare inconsistency. the following is the [D spec on rectangular arrays](https://dlang.org/spec/arrays.html#rectangular-arrays): ``` void main() { import std.stdio: write, writeln, writef, writefln; double[6][3] matrix = 0; // Sets all elements to 0.

Re: Flaoting point operations : unexpected results

2021-06-11 Thread frame via Digitalmars-d-learn
On Thursday, 10 June 2021 at 20:18:03 UTC, seany wrote: On Thursday, 10 June 2021 at 19:51:51 UTC, Dennis wrote: On Thursday, 10 June 2021 at 19:37:36 UTC, seany wrote: However, i sometimes see, that the results are _radically_ different. Are you using uninitialized memory or