Re: Possible bug in associative array implementation (and/or @safe checking)

2018-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/18 4:45 PM, Aaron D. Trout wrote: On Thursday, 16 August 2018 at 18:56:45 UTC, Steven Schveighoffer wrote: On 8/16/18 2:32 PM, Aaron D. Trout wrote: [...] On Thursday, 16 August 2018 at 17:20:23 UTC, Steven Schveighoffer wrote: Yes, this is the effect I would expect. D has traditiona

Re: Possible bug in associative array implementation (and/or @safe checking)

2018-08-16 Thread Aaron D. Trout via Digitalmars-d-learn
Thanks again for the quick reply! I have a pretty firm grasp on what a slice is (array + offset). Argh! Of course my brain would fail in that sentence! :-) I meant (pointer + offest). -Aaron

Re: Possible bug in associative array implementation (and/or @safe checking)

2018-08-16 Thread Aaron D. Trout via Digitalmars-d-learn
On Thursday, 16 August 2018 at 18:56:45 UTC, Steven Schveighoffer wrote: On 8/16/18 2:32 PM, Aaron D. Trout wrote: [...] On Thursday, 16 August 2018 at 17:20:23 UTC, Steven Schveighoffer wrote: Yes, this is the effect I would expect. D has traditionally simply allowed slicing stack data with

Re: Possible bug in associative array implementation (and/or @safe checking)

2018-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/18 2:32 PM, Aaron D. Trout wrote: [...] On Thursday, 16 August 2018 at 17:20:23 UTC, Steven Schveighoffer wrote: Yes, this is the effect I would expect. D has traditionally simply allowed slicing stack data without question (even in @safe code), but that will change when dip1000 is fu

Re: Possible bug in associative array implementation (and/or @safe checking)

2018-08-16 Thread Aaron D. Trout via Digitalmars-d-learn
[...] On Thursday, 16 August 2018 at 17:20:23 UTC, Steven Schveighoffer wrote: Yes, this is the effect I would expect. D has traditionally simply allowed slicing stack data without question (even in @safe code), but that will change when dip1000 is fully realized. It will be allowed, but onl

Re: Possible bug in associative array implementation (and/or @safe checking)

2018-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/18 12:51 PM, Aaron D. Trout wrote: Hello all! I'm a mathematician at Chatham University in Pittsburgh, PA (USA). I use D for research, and I'm a frequent lurker on the forums. I think I found a bug, but I want to make sure I'm not just doing something silly. (I'm happy to file a bugzill

Re: Possible bug

2016-07-05 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 13:48:50 UTC, ag0aep6g wrote: Something is also going wrong in dmd. There should be a deprecation message. Exactly.

Re: Possible bug

2016-07-05 Thread ag0aep6g via Digitalmars-d-learn
On 07/05/2016 12:47 PM, Jack Applegame wrote: ttt.d import std.string; void main() { lastIndexOf("aa","bb"); } rdmd ttt.d compiles successfully without any errors or warnings rdmd -dw ttt.d compiles successfully without any errors or warnings rdmd -de ttt.d /usr/include/dmd/phobos/std

Re: Possible bug in RVO?

2016-04-04 Thread Yuxuan Shui via Digitalmars-d-learn
On Monday, 4 April 2016 at 21:31:08 UTC, Ali Çehreli wrote: On 04/04/2016 09:36 AM, Anonymouse wrote: On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: [...] assert(x.aa.length > 0); // <-- boom [...] No idea myself but that's where it seems to go wrong. Looks like

Re: Possible bug in RVO?

2016-04-04 Thread Ali Çehreli via Digitalmars-d-learn
On 04/04/2016 09:36 AM, Anonymouse wrote: On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: auto clobber(ref Set x, ref Set o) { Set ret; ret.aa = x.aa; assert(x.aa.length > 0); // <-- boom return ret; }

Re: Possible bug in RVO?

2016-04-04 Thread Anonymouse via Digitalmars-d-learn
On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: auto clobber(ref Set x, ref Set o) { Set ret; ret.aa = x.aa; assert(x.aa.length > 0); // <-- boom return ret; } No idea myself but that's

Re: Possible bug in RVO?

2016-04-03 Thread Yuxuan Shui via Digitalmars-d-learn
On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: I have encountered a weird bug. I defined a Set class, which has a opBinary!"-". And somehow this: auto tmp = set_a-set_b; produces different results as this: set_a = set_a-set_b; the latter will produce an empty set. I tried to

Re: Possible bug in RVO?

2016-04-03 Thread Yuxuan Shui via Digitalmars-d-learn
On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: I have encountered a weird bug. I defined a Set class, which has a opBinary!"-". And somehow this: auto tmp = set_a-set_b; produces different results as this: set_a = set

Re: Possible bug in RVO?

2016-04-03 Thread Yuxuan Shui via Digitalmars-d-learn
On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: I have encountered a weird bug. I defined a Set class, which has a opBinary!"-". And somehow this: auto tmp = set_a-set_b; produces different results as this: set_a = set_a-set_b; the latter will produce an empty set. I tried to

Re: Possible bug - should the following code cause an access violation exception?

2013-12-30 Thread Ali Çehreli
On 12/30/2013 04:55 PM, Afshin wrote: Thanks Ali. I uninstalled 2.63.x. Installed the 2.64.2. I compiled and ran the test, and surely enough there were no problems. However, when I build using Visual D environment, the problem persists. Microsoft Visual Studio 2010 Ultimate. Visual D plugin.

Re: Possible bug - should the following code cause an access violation exception?

2013-12-30 Thread Afshin
Thanks Ali. I uninstalled 2.63.x. Installed the 2.64.2. I compiled and ran the test, and surely enough there were no problems. However, when I build using Visual D environment, the problem persists. Microsoft Visual Studio 2010 Ultimate. Visual D plugin. Thankfully, there is a simple work

Re: Possible bug - should the following code cause an access violation exception?

2013-12-30 Thread Ali Çehreli
On 12/29/2013 10:38 PM, Afshin wrote: module test; class Foo { public static ulong next = 0; public static ulong getNext() { return next++; } } void main() { Foo.getNext(); } /* The next++ is the culprit. Using a ++next does not throw an exception. */ Must have

Re: Possible bug

2013-03-26 Thread Sergei Nosov
On Tuesday, 26 March 2013 at 05:40:00 UTC, Steven Schveighoffer wrote: What you have to do is instantiate the template, then call the constructor: S!(int, 4).S!(byte, 5)(3) Note that the way templates work in D, a templated struct is really a shortcut for: template S(T) { struct S { ...

Re: Possible bug

2013-03-25 Thread Steven Schveighoffer
On Tue, 26 Mar 2013 01:28:03 -0400, Sergei Nosov wrote: Thank you, guys! You made the matters clear to me! It would be an interesting enhancement over C++. Although, Steven, I didn't quite understand what you're suggesting to use in case of "templated-struct-templated-constructor" Expl

Re: Possible bug

2013-03-25 Thread Sergei Nosov
Thank you, guys! You made the matters clear to me! It would be an interesting enhancement over C++. Although, Steven, I didn't quite understand what you're suggesting to use in case of "templated-struct-templated-constructor" Explicitly specifying struct parameters is ok. Deducing construc

Re: Possible bug

2013-03-25 Thread Steven Schveighoffer
On Mon, 25 Mar 2013 17:13:58 -0400, Ali Çehreli wrote: On 03/25/2013 12:40 PM, Steven Schveighoffer wrote: > On Mon, 25 Mar 2013 11:31:17 -0400, Ali Çehreli wrote: > >> This design allows templated constructors: >> >> struct S // <-- not a template >> { >> this(T)(T t) // <-- templat

Re: Possible bug

2013-03-25 Thread Ali Çehreli
On 03/25/2013 12:40 PM, Steven Schveighoffer wrote: > On Mon, 25 Mar 2013 11:31:17 -0400, Ali Çehreli wrote: > >> This design allows templated constructors: >> >> struct S // <-- not a template >> { >> this(T)(T t) // <-- template >> { >> // ... >> } >> >> // ... >> } >> >> The same in C++... >

Re: Possible bug

2013-03-25 Thread Steven Schveighoffer
On Mon, 25 Mar 2013 11:31:17 -0400, Ali Çehreli wrote: This design allows templated constructors: struct S // <-- not a template { this(T)(T t) // <-- template { // ... } // ... } The same in C++... Templated constructors would not be disallowed if you

Re: Possible bug

2013-03-25 Thread Steven Schveighoffer
On Mon, 25 Mar 2013 11:11:40 -0400, Sergei Nosov wrote: On Monday, 25 March 2013 at 14:12:17 UTC, bearophile wrote: Sergei Nosov: Everything's fine if I specify parameters explicitly: test!int hello = test!int(cptr); Some persons have proposed alternative designs, but D is working as c

Re: Possible bug

2013-03-25 Thread Ali Çehreli
On 03/25/2013 08:11 AM, Sergei Nosov wrote: > On Monday, 25 March 2013 at 14:12:17 UTC, bearophile wrote: >> Sergei Nosov: >> >>> Everything's fine if I specify parameters explicitly: >>> >>> test!int hello = test!int(cptr); >>> >> >> Some persons have proposed alternative designs, but D is work

Re: Possible bug

2013-03-25 Thread Sergei Nosov
On Monday, 25 March 2013 at 14:12:17 UTC, bearophile wrote: Sergei Nosov: Everything's fine if I specify parameters explicitly: test!int hello = test!int(cptr); Some persons have proposed alternative designs, but D is working as currently designed here... Unlike template functions, templa

Re: Possible bug

2013-03-25 Thread bearophile
Sergei Nosov: Everything's fine if I specify parameters explicitly: test!int hello = test!int(cptr); Some persons have proposed alternative designs, but D is working as currently designed here... Unlike template functions, templated structs don't infer the type. Bye, bearophile