Re: Coverage (-cov)

2017-09-23 Thread Tony via Digitalmars-d-learn

On Sunday, 24 September 2017 at 05:48:32 UTC, Tony wrote:
I am compiling a module (utils) with one function in it with 
the -cov compiler option on Ubuntu 14.04 with DMD v2.073.2. I 
then compile a "main module" with -cov that imports the "utils 
module" and calls the one function. The *.lst output file shows 
lines that executed in the "main module". I would like it to 
also show lines that executed in the module that was imported. 
Is this possible?


Oops. Never mind. I just noticed the utils.lst output file.


Coverage (-cov)

2017-09-23 Thread Tony via Digitalmars-d-learn
I am compiling a module (utils) with one function in it with the 
-cov compiler option on Ubuntu 14.04 with DMD v2.073.2. I then 
compile a "main module" with -cov that imports the "utils module" 
and calls the one function. The *.lst output file shows lines 
that executed in the "main module". I would like it to also show 
lines that executed in the module that was imported. Is this 
possible?


Re: Connecting python to D on socket of localhost : target machine actively refuses connection

2017-09-23 Thread Sergei Degtiarev via Digitalmars-d-learn
On Saturday, 23 September 2017 at 02:50:25 UTC, rikki cattermole 
wrote:

On 23/09/2017 3:26 AM, Sergei Degtiarev wrote:
On Friday, 22 September 2017 at 04:06:08 UTC, Enjoys Math 
wrote:


Here's my minimal D code (server.d):
public:
this(ushort port, string address="") {
    super(& run);

    if (address == "")
    address = "DESKTOP-T49RGUJ";

    this.port = port;
    this.address = address;

.

    listener.bind(new InternetAddress(address, port));


It seems to me, you pass invalid address to bind(). 
InternetAddress takes ipv4 dot notation string x.x.x.x, and 
for bind you are to supply INADDR_ANY




For DNS resolution:
https://dlang.org/phobos/std_socket.html#.getAddress


Right, but in this case, it would be sufficient to bind socket to 
INADDR_ANY.


Re: Why isn't there more if( ctfe) in std.math ?

2017-09-23 Thread ketmar via Digitalmars-d-learn

user1234 wrote:

"if (__ctfe) {}" is a test happening at runtime. Both the if and the else 
branches got compiled


nope. compiler knows about this special pseudovariable, and will not 
generate code neither for condition, nor for ctfe branch.


Re: Why isn't there more if(__ctfe) in std.math ?

2017-09-23 Thread ag0aep6g via Digitalmars-d-learn

On 09/23/2017 11:46 PM, user1234 wrote:
"if (__ctfe) {}" is a test happening at runtime. Both the if and the 
else branches got compiled, this implies:

- more code to cache
- slower code
just to allow CTFE.


__ctfe is a constant, though. Any half-decent optimizer will throw away 
the path that's not taken. dmd does it even without the optimization 
flag -O.


Re: Why isn't there more if(__ctfe) in std.math ?

2017-09-23 Thread user1234 via Digitalmars-d-learn
On Saturday, 23 September 2017 at 18:23:12 UTC, Juraj Mojzis 
wrote:

Hi,
browsing trough phobos bugzilla I found a couple of open issues 
regarding CTFE and basic math functions ( Issue 4177, 5227).
It looks to me that at least floor/ceil could by fixed by a 
simple:

if (__ctfe) return simple_floor_impl(x);

But that looks too easy and would surely be implemented 
already. So I would like to ask what the real problems are.


Thanks,
Juraj


"if (__ctfe) {}" is a test happening at runtime. Both the if and 
the else branches got compiled, this implies:

- more code to cache
- slower code
just to allow CTFE.


CTFE rounding can be more simply done using cast(int), although 
for negative numbers the behavior is not the same.


Re: What the hell is wrong with D?

2017-09-23 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 18:34:13 UTC, Brad Anderson 
wrote:

On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


It is (and Java and C# and pretty much every other C style 
language though the nicer implicit conversion rules means it 
gets caught more easily). It is a big source of programmer 
mistakes. It comes up frequently in PVS Studio's open source 
analysis write ups.


So I checked for all the languages listed: C, C#, Java, 
Javascript, C++, PHP, Perl and D. All have the same order of 
precedence except, as always the abomination of all languages: 
C++ (kill it with fire).
C++ is the only language that has the ternary operator have the 
same precedence than the assignment operators.
This means a>=5?b=100:b=200; will compile in C++ but not in all 
the other languages. That's one reason why it irritates me when 
people continuously refer to C and C++ as if it was the same 
thing (yes I mean you Walter and Andrei).
Even PHP and Perl got it right, isn't that testament of poor 
taste Bjarne?. :-)





Why isn't there more if(__ctfe) in std.math ?

2017-09-23 Thread Juraj Mojzis via Digitalmars-d-learn

Hi,
browsing trough phobos bugzilla I found a couple of open issues 
regarding CTFE and basic math functions ( Issue 4177, 5227).
It looks to me that at least floor/ceil could by fixed by a 
simple:

if (__ctfe) return simple_floor_impl(x);

But that looks too easy and would surely be implemented already. 
So I would like to ask what the real problems are.


Thanks,
Juraj


detect implicitly convertible typeid's?

2017-09-23 Thread bitwise via Digitalmars-d-learn
Is it possible to tell if two objects represented by TypeInfo's 
are convertible to each other?


Basically, is there a built in way to do this?

int x;
long y;
assert(typeid(x).isImplicitlyConvertibleTo(typeid(y));

   Thanks


Re: Cannot make LDC use LTO when called via DUB

2017-09-23 Thread Nordlöw via Digitalmars-d-learn

On Saturday, 23 September 2017 at 15:19:09 UTC, Nordlöw wrote:

I've added

buildType "release" {
 buildOptions "releaseMode" "optimize" "inline"
 dflags-posix-ldc "-flto=thin" "-Xcc=-fuse-ld=gold"
}

to my dub.sdl and built (on Linux) as

/usr/bin/dub -v run --compiler=ldc2 --build=release

but neither the flag "-flto=thin" nor "-Xcc=-fuse-ld=gold" is 
propagated to the ldc2 call (at least no printed on stdout).


What's missing?


Neither

dflags-dmd "-xxx"
dflags-posix-dmd "-xxx"
dflags-linux-dmd "-xxx"

has any effect on my build (in dub.sdl).


Cannot make LDC use LTO when called via DUB

2017-09-23 Thread Nordlöw via Digitalmars-d-learn

I've added

buildType "release" {
 buildOptions "releaseMode" "optimize" "inline"
 dflags-posix-ldc "-flto=thin" "-Xcc=-fuse-ld=gold"
}

to my dub.sdl and built (on Linux) as

/usr/bin/dub -v run --compiler=ldc2 --build=release

but neither the flag "-flto=thin" nor "-Xcc=-fuse-ld=gold" is 
propagated to the ldc2 call (at least no printed on stdout).


What's missing?


Re: how to build project with locally compiled phobos

2017-09-23 Thread Mike Wey via Digitalmars-d-learn

On 23-09-17 13:58, Mengu wrote:

hi all

i've successfully compiled phobos master with gmake on freebsd. (make 
fails, i've no clue at all as to why)


how do i compile my project now against my local phobos with dub? with 
plain dmd?


i tried (in dub.sdl):
- full path to new libphobos.so with -defaultlib to dflags
- full path to new libphobos.so to lflags

i checked with ldd and saw the original libphobos.so was used. my 
current workaround is copying mine to /usr/lib.


thanks in advanced.


While you are linking with the phobos you compiled yourself with 
-defaultlib, ldd (and your binary) will pickup the one available in one 
of the paths configured for the run-time shared library loader.


To actually make use of the phobos you compiled you also need to set the 
rpath.


```
-L-rpath=/path/to/phobos
```

Or use phobos as a static library.

--
Mike Wey


Re: how to build project with locally compiled phobos

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn

On Saturday, 23 September 2017 at 11:58:40 UTC, Mengu wrote:

hi all

i've successfully compiled phobos master with gmake on freebsd. 
(make fails, i've no clue at all as to why)


how do i compile my project now against my local phobos with 
dub? with plain dmd?


i tried (in dub.sdl):
- full path to new libphobos.so with -defaultlib to dflags
- full path to new libphobos.so to lflags

i checked with ldd and saw the original libphobos.so was used. 
my current workaround is copying mine to /usr/lib.


thanks in advanced.


try changing the dmd.conf file that is next to the dmd binary. My 
current one looks like


[Environment]
DFLAGS=-I~/d/druntime/import -I~/d/import -I~/d/phobos 
-L-L/Users/nicholaswilson/d/lib/


just change the -I and -L-L flags to the appropriate locations. 
or use the -conf switch (-conf=/path/to/newdmd.conf)





Re: how to build project with locally compiled phobos

2017-09-23 Thread B4s1L3 via Digitalmars-d-learn

On Saturday, 23 September 2017 at 11:58:40 UTC, Mengu wrote:

hi all

i've successfully compiled phobos master with gmake on freebsd. 
(make fails, i've no clue at all as to why)


how do i compile my project now against my local phobos with 
dub? with plain dmd?


i tried (in dub.sdl):
- full path to new libphobos.so with -defaultlib to dflags
- full path to new libphobos.so to lflags

i checked with ldd and saw the original libphobos.so was used. 
my current workaround is copying mine to /usr/lib.


thanks in advanced.


Hello, what you want to do is certainly possible but... I'd 
rather build a full custom dmd+runtime+phobos with its own 
sc.conf file Why ?

- Easier to invoke dub w/ the option --compiler=path.
- The custom DMD will alsways use the right phobos (when not 
using dub).





how to build project with locally compiled phobos

2017-09-23 Thread Mengu via Digitalmars-d-learn

hi all

i've successfully compiled phobos master with gmake on freebsd. 
(make fails, i've no clue at all as to why)


how do i compile my project now against my local phobos with dub? 
with plain dmd?


i tried (in dub.sdl):
- full path to new libphobos.so with -defaultlib to dflags
- full path to new libphobos.so to lflags

i checked with ldd and saw the original libphobos.so was used. my 
current workaround is copying mine to /usr/lib.


thanks in advanced.


Re: [FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Mengu via Digitalmars-d-learn
On Saturday, 23 September 2017 at 11:23:26 UTC, Nicholas Wilson 
wrote:

On Saturday, 23 September 2017 at 08:45:00 UTC, Mengu wrote:

[...]


So it fails:
trying to find if an element exists in an AA
in a regex
invoked as a callback from curl
inside a parallel foreach.

Interesting that it just straight up core dumps, usually you'll 
get an exception.
see 
https://forum.dlang.org/thread/rrpmgzqqtkqgeicjd...@forum.dlang.org for a recent discussion. What it the stack limit? 35 frames is a fair bit, could be a stack overflow. What is the return code? this will probably give you some info as to what happened.


Only other thing I can suggest is try linking against a debug 
phobos to see if you can get some more diagnostics.


hi nicholas

the latter is what i did. i re-compiled phobos master and used 
it. this time everything worked as expected.


btw, regex match happens in HTTP.Impl.onReceiveHeader. i think it 
no longer had access to that header to parse.


Re: [FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 11:23:26 UTC, Nicholas Wilson 
wrote:
Only other thing I can suggest is try linking against a debug 
phobos to see if you can get some more diagnostics.


You might also try LDC's -fsanitize=address option for catching 
memory bugs.




Re: [FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn

On Saturday, 23 September 2017 at 08:45:00 UTC, Mengu wrote:

hello everyone

i have a small program that parses an xml file, holding a list 
with 13610 elements. after making the list, it iterates over 
the list (paralele), goes to a web site and grabs the related 
data for that element.


it works perfect for the first 1K element in the list. after 
that i get a very annoying segmentation fault. no exceptions, 
nothing. it just dumps a core file. below is the full stack 
trace. (also available at https://pastebin.com/PT1R5D7S)


i appreciate any help.

my dmd info:
DMD64 D Compiler v2.076.0-dirty
Copyright (c) 1999-2017 by Digital Mars written by Walter Bright

my os info:
FreeBSD metropol.com 11.1-RELEASE FreeBSD 11.1-RELEASE #0 
r321309: Fri Jul 21 02:08:28 UTC 2017 
r...@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64




(gdb) bt full
[...]


So it fails:
trying to find if an element exists in an AA
in a regex
invoked as a callback from curl
inside a parallel foreach.

Interesting that it just straight up core dumps, usually you'll 
get an exception.
see 
https://forum.dlang.org/thread/rrpmgzqqtkqgeicjd...@forum.dlang.org for a recent discussion. What it the stack limit? 35 frames is a fair bit, could be a stack overflow. What is the return code? this will probably give you some info as to what happened.


Only other thing I can suggest is try linking against a debug 
phobos to see if you can get some more diagnostics.


Re: Dub use local fork

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 09:37:54 UTC, rikki cattermole 
wrote:

On 23/09/2017 10:34 AM, Guillaume Piolat wrote:
On Saturday, 23 September 2017 at 03:16:30 UTC, rikki 
cattermole wrote:


Alternatively you can alter the package that dub already 
knows about.

Does the trick more easily ;)


+1
That's the dirty trick I'm using too


You can also do the same for Phobos+druntime when it comes to 
templated symbols. Of course it won't redownload if you delete 
the file, so gotta be a bit more careful. But a wonderful way 
to confirm that your fix actually fixes it before a PR.


Heh, I'm used to swapping out Phobos/Druntime from fiddling with 
the compiler.
But in this case I'm adding functionality so I want to make sure 
that it a) compiles (I forgot a semicolon and one symbol) and b) 
works the way I think it does. That's a little trickier when 
things are spread over more than one repo and dub is involved. 
Hopefully I should have dcompute kernels running on OpenCL 2.x 
very soon.


Re: Dub use local fork

2017-09-23 Thread rikki cattermole via Digitalmars-d-learn

On 23/09/2017 10:34 AM, Guillaume Piolat wrote:

On Saturday, 23 September 2017 at 03:16:30 UTC, rikki cattermole wrote:


Alternatively you can alter the package that dub already knows about.
Does the trick more easily ;)


+1
That's the dirty trick I'm using too


You can also do the same for Phobos+druntime when it comes to templated 
symbols. Of course it won't redownload if you delete the file, so gotta 
be a bit more careful. But a wonderful way to confirm that your fix 
actually fixes it before a PR.


Re: Dub use local fork

2017-09-23 Thread Guillaume Piolat via Digitalmars-d-learn
On Saturday, 23 September 2017 at 03:16:30 UTC, rikki cattermole 
wrote:


Alternatively you can alter the package that dub already knows 
about.

Does the trick more easily ;)


+1
That's the dirty trick I'm using too


[FreeBSD] 0x000000000061d8cd in rt.aaA.Impl.findSlotLookup(ulong, const(void*), const(TypeInfo)) inout ()

2017-09-23 Thread Mengu via Digitalmars-d-learn

hello everyone

i have a small program that parses an xml file, holding a list 
with 13610 elements. after making the list, it iterates over the 
list (paralele), goes to a web site and grabs the related data 
for that element.


it works perfect for the first 1K element in the list. after that 
i get a very annoying segmentation fault. no exceptions, nothing. 
it just dumps a core file. below is the full stack trace. (also 
available at https://pastebin.com/PT1R5D7S)


i appreciate any help.

my dmd info:
DMD64 D Compiler v2.076.0-dirty
Copyright (c) 1999-2017 by Digital Mars written by Walter Bright

my os info:
FreeBSD metropol.com 11.1-RELEASE FreeBSD 11.1-RELEASE #0 
r321309: Fri Jul 21 02:08:28 UTC 2017 
r...@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64




(gdb) bt full
#0  0x0061d8cd in rt.aaA.Impl.findSlotLookup(ulong, 
const(void*), const(TypeInfo)) inout ()

No symbol table info available.
#1  0x005dcb21 in _aaInX ()
No symbol table info available.
#2  0x0067fef0 in 
std.regex.internal.ir.getMatcher(std.uni.InversionList!(std.uni.GcPolicy).InversionList) ()

No symbol table info available.
#3  0x00677a26 in 
std.regex.internal.parser.CodeGen.charsetToIr(std.uni.InversionList!(std.uni.GcPolicy).InversionList) ()

No symbol table info available.
#4  0x00655f47 in 
std.regex.internal.parser.Parser!(immutable(char)[], 
std.regex.internal.parser.CodeGen).Parser.parseEscape() ()

No symbol table info available.
#5  0x00654680 in 
std.regex.internal.parser.Parser!(immutable(char)[], 
std.regex.internal.parser.CodeGen).Parser.parseAtom() ()

No symbol table info available.
#6  0x006541e3 in 
std.regex.internal.parser.Parser!(immutable(char)[], 
std.regex.internal.parser.CodeGen).Parser.parseRegex() ()

No symbol table info available.
#7  0x006570f0 in 
std.regex.internal.parser.Parser!(immutable(char)[], 
std.regex.internal.parser.CodeGen).Parser.this!(const(char)[]).this(immutable(char)[], const(char)[]) ()

No symbol table info available.
#8  0x00652fb1 in 
std.regex.regexImpl!(immutable(char)[]).regexImpl(immutable(char)[], const(char)[]) ()

No symbol table info available.
#9  0x00636af3 in 
std.functional.memoize!(std.regex.regexImpl!(immutable(char)[]).regexImpl(immutable(char)[], const(char)[]), 8).memoize(immutable(char)[], const(char)[]) ()

No symbol table info available.
#10 0x005fd617 in 
std.regex.regex!(immutable(char)[]).regex(immutable(char)[][], 
const(char)[]) ()

No symbol table info available.
#11 0x005fd472 in 
std.regex.regex!(immutable(char)[]).regex(immutable(char)[], 
const(char)[]) ()

No symbol table info available.
#12 0x005f7bb7 in 
std.net.curl.HTTP.Impl.onReceiveHeader(void(const(char[]), 
const(char[])) delegate).__lambda2(const(char[])) ()

No symbol table info available.
#13 0x005fb98a in 
std.net.curl.Curl.onReceiveHeader(void(const(char[])) 
delegate).__lambda2(const(char[])) ()

No symbol table info available.
#14 0x005fbdce in 
std.net.curl.Curl._receiveHeaderCallback(const(char*), ulong, 
ulong, void*) ()

No symbol table info available.
#15 0x00080681838b in ?? () from /usr/local/lib/libcurl.so
No symbol table info available.
#16 0x000806816c95 in ?? () from /usr/local/lib/libcurl.so
No symbol table info available.
#17 0x00080683119c in ?? () from /usr/local/lib/libcurl.so
No symbol table info available.
#18 0x00080683bd94 in ?? () from /usr/local/lib/libcurl.so
No symbol table info available.
---Type  to continue, or q  to quit---
#19 0x00080683b56b in curl_multi_perform () from 
/usr/local/lib/libcurl.so

No symbol table info available.
#20 0x0008068334b0 in curl_easy_perform () from 
/usr/local/lib/libcurl.so

No symbol table info available.
#21 0x005fb77c in 
std.net.curl.Curl.perform(std.typecons.Flag!("throwOnError").Flag) ()

No symbol table info available.
#22 0x005f8a20 in 
std.net.curl.HTTP.perform(std.typecons.Flag!("throwOnError").Flag) ()

No symbol table info available.
#23 0x005cff60 in 
provider.SunHotels.getHotels(destination.Destination) 
(this=0x80097e000, destination=...) at source/provider.d:226

__closptr = 0x800980800
filePath = 
"/usr/home/search-master/search-api/ext/data/hotels/6593.xml"

__dollar = 7
hotelsPath = "http://some-domain.com;
data = {ptr = 0x80097f240}
http = {p = {_refCounted = {_store = 0x805a14000}}}
postData = "some=postData"
__flag = 2
__EAX = 0x8002901170
__exception_object = 0x0
__EAX = 0x8002901170
__EDX = -851895465
__handler = 0
__exception_object = 0x801f12540
#24 0x0059cdb2 in 
app.getDestinations().__foreachbody1(ref destination.Destination) 
(this=0x7fffe850, __applyArg0=...) at source/app.d:164
destination = {destinationId = 6593, destinationCode = 
"GRR", destinationCode_1 = 0x0, 

Re: CTFE static array error: cannot modify read-only constant

2017-09-23 Thread Petar via Digitalmars-d-learn

On Friday, 22 September 2017 at 14:43:28 UTC, Johan wrote:

Hi all,
```
  auto foo(const int[3] x)
  {
  int[3] y = x;
  y[0] = 1; // line 4
  return y;
  }
  immutable int[3] a = [0,1,2];
  immutable int[3] b = foo(a); // line 8
```
compiles with an error:
```
4: Error: cannot modify read-only constant [0, 1, 2]
8:called from here: foo(a)
```

What am I doing wrong?

Thanks,
  Johan


Looks like a compiler bug to me. Please file a bug report on 
https://issues.dlang.org/enter_bug.cgi


Re: Dub use local fork

2017-09-23 Thread Nicholas Wilson via Digitalmars-d-learn

On Saturday, 23 September 2017 at 04:45:47 UTC, Mike Parker wrote:
On Saturday, 23 September 2017 at 03:13:15 UTC, Nicholas Wilson 
wrote:



my dub.selections.json is currently:

{
"fileVersion": 1,
"versions": {
"derelict-cl": "2.0.0",
"derelict-cuda": "2.0.1",
"derelict-util": "2.1.0",
"taggedalgebraic": "0.10.7"
}
}

I want derelict-cl to use
C:\Users\me\Documents\GitHub\DerelictCL

How do I do that?



http://code.dlang.org/package-format?lang=json#version-specs

"derelict-cl": { "path": 
"C:/Users/me/Documents/GitHub/DerelictCL" }


Thanks!