Re: Bug or expected?

2019-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/8/19 3:12 PM, SrMordred wrote: size_t[2] a; size_t[2] b; auto x  = a[] & b[]; //array operation without destination memory not allowed size_t[2] y = a[] & b[]; // fine Honestly, I wouldn't have expected either to work. My understanding was that array operations require slicing on

Bug or expected?

2019-01-08 Thread SrMordred via Digitalmars-d-learn
size_t[2] a; size_t[2] b; auto x = a[] & b[]; //array operation without destination memory not allowed size_t[2] y = a[] & b[]; // fine

Re: Do I need to use static here?

2019-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/8/19 1:35 PM, Machine Code wrote: I'm using enum to compute the value at runtime like this: struct A { enum foo = A("foo", 10); enum baa = A("baa", 20); string name; int value; alias value this; } In order to avoid foo having its value (even if literal) copied

Do I need to use static here?

2019-01-08 Thread Machine Code via Digitalmars-d-learn
I'm using enum to compute the value at runtime like this: struct A { enum foo = A("foo", 10); enum baa = A("baa", 20); string name; int value; alias value this; } In order to avoid foo having its value (even if literal) copied every time A instancied

Re: Understanding SIGSEGV issues

2019-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/19 6:33 AM, Russel Winder wrote: On Sat, 2019-01-05 at 10:52 +, Russel Winder wrote: On Sat, 2019-01-05 at 10:31 +, Nicholas Wilson via Digitalmars-d-learn wrote: […] Maybe it is a problem with copying a File_Ptr (e.g. missing a increase of the reference count)? Like, `auto a =

Re: Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-08 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 12:54:11 UTC, RazvanN wrote: Hi all, I am working on issue 14650 [1] Great! (I am _extremely_ surprised that dtors are not called for globals.) and I would like to implement a solution where static destructors are destroying global variables. However, I have

Re: Bitwise rotate of integral

2019-01-08 Thread Reimer Behrends via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 09:15:09 UTC, Patrick Schluter wrote: Are you sure it's dmd looking for the pattern. Playing with the godbolt link shows that dmd doesn't generate the rol code (gdc 4.8.2 neither). Looking at the dmd compiler source code, it requires the value to be rotated to

Re: Bitwise rotate of integral

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 12:35:16 UTC, H. S. Teoh wrote: On Tue, Jan 08, 2019 at 09:15:09AM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: [...] > [...] Are you sure it's dmd looking for the pattern. Playing with the

Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-08 Thread RazvanN via Digitalmars-d-learn
Hi all, I am working on issue 14650 [1] and I would like to implement a solution where static destructors are destroying global variables. However, I have the following problem in druntime/src/rt/sections_elf_shared: struct ThreadDSO { DSO* _pdso; static if (_pdso.sizeof == 8) uint

Re: Bitwise rotate of integral

2019-01-08 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 08, 2019 at 09:15:09AM +, Patrick Schluter via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: [...] > > There's a certain pattern that dmd looks for, that it transforms > > into a ROL instruction. Similarly for ROR. Deviate too far from

Re: Understanding SIGSEGV issues

2019-01-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 10:23:30 UTC, Russel Winder wrote: Actually that is not a worry since the TransmitterData instance is only needed to call the scan function which creates a ChannelsData instance that holds no references to the TransmitterData instance. It turns out that whilst

Re: signed nibble

2019-01-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 10:55:59 UTC, Patrick Schluter wrote: The cycle counts for 6502 are pretty easy though as they tend to be related to the addressing mode and most of them are in the range 1-5... No instruction for multiplication or division... Oh the fun... 2-7 cycles ;-)

Re: signed nibble

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 10:32:25 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 8 January 2019 at 09:30:14 UTC, Patrick Schluter wrote: [...] Heh, I remember they had a friday-night trivia contest at the mid-90s students pub (for natural sciences) where one of the questions was the

Re: Bitwise rotate of integral

2019-01-08 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: What's the preferred way of doing bitwise rotate of an integral value in D? Are there intrinsics for bitwise rotation available in LDC? LDC does not expose this intrinsic currently, but you can use LLVM's fshl:

Re: signed nibble

2019-01-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 09:30:14 UTC, Patrick Schluter wrote: During the PC revolution I wrote an entire application in 8088 assembly. Used to know many of the opcodes and cycle counts by heart like you do, but it's all but a faint memory now. I had to lookup the exact cycle counts ;-)

Re: Understanding SIGSEGV issues

2019-01-08 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2019-01-05 at 13:14 +, Nicholas Wilson via Digitalmars-d-learn wrote: > […] > Your problem possibly (probably?) stems from > > auto channelsData = TransmitterData(args[1]).scan(frontendId); > > The temporary TransmitterData(args[1]) is, well, temporary and > its destructor runs

Re: signed nibble

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 21:46:21 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 08:41:32PM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 20:28:21 UTC, H. S. Teoh wrote: > On Mon, Jan 07, 2019 at 08:06:17PM +, Patrick Schluter > via

Re: Bitwise rotate of integral

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 11:13:37PM +, Guillaume Piolat via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: > What's the preferred way of doing bitwise rotate of an > integral value in D? >