toChars Bug?

2017-12-12 Thread Bottled Gin via Digitalmars-d
Greetings This small code snippet works: // import std.conv; import std.stdio; void main() { writeln(toChars!10(45)); } But if I change toChars!10 with toChars!2, I get: /tmp/test.d(6): Error: template std.conv.toChars cannot deduce function from argument types !(2)(int), candidates are:

Re: Memory Corruption Issue??

2016-03-09 Thread Bottled Gin via Digitalmars-d
The fix turned out to be much simpler than what I had thought. https://github.com/D-Programming-Language/druntime/pull/1506

Re: Memory Corruption Issue??

2016-03-06 Thread Bottled Gin via Digitalmars-d
Greetings I am using my D code as a dynamically loadable library that gets loaded at run time into C/C++ world. As discussed earlier on this thread, the GC does not mark TLS objects in this scenario and as a result the GC ends up collecting TLS objects even though these objects are still in

Re: Poor memory allocation performance with a lot of threads on 36 core machine

2016-02-19 Thread Bottled Gin via Digitalmars-d
On Thursday, 18 February 2016 at 13:00:12 UTC, Witek wrote: Anyhow, everything was good on 1 or 2 threads, or maybe few more, on my laptop with old Dual Core CPU. I was able to speed it up exactly by a factor of 2x. I wanted to try it out on bigger machine, so used Amazone AWS EC2

Re: Head Const

2016-02-18 Thread Bottled Gin via Digitalmars-d
Too illustrate how headconst can help with multithreading (shared memory) code, I have created this small snippet. In my experience, there are lots of *effectively immutable* objects (like Foo.bar in the code snippet). If these variables can be declared headconst, a lot of hierarchical

Re: Head Const

2016-02-17 Thread Bottled Gin via Digitalmars-d
Greetings Having coded a multithreaded library in D, I sorely miss headcost like specifier. The library code dealt with lots of composite class object hierarchy where many element objects of a parent are *effectively immutable*. You build an effectively immutable object in the constructor

Re: Memory Corruption Issue??

2016-01-20 Thread Bottled Gin via Digitalmars-d
Thanks Daniel I have added the testcase to a more obscure testcase that I had raised on Bugzilla earlier. https://issues.dlang.org/show_bug.cgi?id=15513 I want to request developers to show some love. Regards - Puneet

Memory Corruption Issue??

2016-01-20 Thread Bottled Gin via Digitalmars-d
Greetings I am struggling with strange memory corruption issues with dmd-2.069.2 release. The issue shows up only when I load a shared library created from D code from C and call some D functions from the C side. But since the program control is completely with the D code, and data

Re: Memory Corruption Issue??

2016-01-20 Thread Bottled Gin via Digitalmars-d
Another workaround is to use GC.addRoot for dynamic allocated data in Dynamic.proc void proc () { import core.memory: GC; dash.length = 32; GC.addRoot(cast(void*)dash.ptr); dash[] = '-'; } And another one is hold pointer to data: class Dynamic { static char[] space;

Re: How to check at compile time if Default Constructor for a class exists?

2016-01-01 Thread Bottled Gin via Digitalmars-d
Thanks Basile/Adam. The templates that you provided work for me.

Re: How to check at compile time if Default Constructor for a class exists?

2016-01-01 Thread Bottled Gin via Digitalmars-d
It seems like saying that a constructor with all default arguments is not a default constructor is a distinction without meaning. What are you doing that you would care? The Object.factory does not seem to consider a constructor with default arguments as a defaultConstructor. Consider the

Re: How to check at compile time if Default Constructor for a class exists?

2016-01-01 Thread Bottled Gin via Digitalmars-d
I think this is related to the bug 3438 that got fixed recently. https://issues.dlang.org/show_bug.cgi?id=3438 Regards - Puneet

How to check at compile time if Default Constructor for a class exists?

2016-01-01 Thread Bottled Gin via Digitalmars-d
Hello Folks When I try using TypeInfo_Class.defaultConstructor during compile time, I get: typeid(Foo).defaultConstructor is not yet implemented at compile time Is there any other way to find out at compile time if a default constructor exists for a given class? Regards - Puneet

Re: How to check at compile time if Default Constructor for a class exists?

2016-01-01 Thread Bottled Gin via Digitalmars-d
You might be able to just do `static if(__traits(compiles, new YourClass()))` and if it returns true then figure it does. That gives me a false positive if a defined constructor has default value for all its arguments.

How to debug Segmentation Fault?

2015-12-13 Thread Bottled Gin via Digitalmars-d
Greetings I am calling a D function from an opensource application coded in C/C++. My code crashes, though there is no reason for it to crash. Also when I call my D function from inside D, it does not crash. The D function does not take any arguments, nor does it try to access any variable