Jump to page: 1 2
Thread overview
February 07

Need help working around a linkage problem.

import std.uni, std.conv, std.stdio, std.format;

void main() {
	//auto c1 = unicode.InBasic_latin;
	auto c1 = CodepointSet('a','z'+1);
	writeln(c1.to!string);
	writeln(format("%d", c1));
	writeln(format("%#x", c1));
	writeln(format("%#X", c1));
	writefln("%s", c1);
}

doesn't link, but does link with the commented out CodepointSet instead. Combines code from these examples at the following URLs.
https://dlang.org/phobos/std_uni.html#InversionList
https://dlang.org/phobos/std_uni.html#.InversionList.toString

$ dmd --version
DMD64 D Compiler v2.107.0
Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright
$ dmd cset2.d
/usr/bin/ld: cset2.o: in function `_D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv':
cset2.d:(.text._D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv[_D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv]+0x19): undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
February 08
On 07/02/2024 7:27 PM, Carl Sturtivant wrote:
> Need help working around a linkage problem.
> ```d
> import std.uni, std.conv, std.stdio, std.format;
> 
> void main() {
>      //auto c1 = unicode.InBasic_latin;
>      auto c1 = CodepointSet('a','z'+1);
>      writeln(c1.to!string);
>      writeln(format("%d", c1));
>      writeln(format("%#x", c1));
>      writeln(format("%#X", c1));
>      writefln("%s", c1);
> }
> ```
> doesn't link, but does link with the commented out CodepointSet instead. Combines code from these examples at the following URLs.
> https://dlang.org/phobos/std_uni.html#InversionList
> https://dlang.org/phobos/std_uni.html#.InversionList.toString
> ```
> $ dmd --version
> DMD64 D Compiler v2.107.0
> Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright
> $ dmd cset2.d
> /usr/bin/ld: cset2.o: in function `_D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv':
> cset2.d:(.text._D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv[_D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv]+0x19): undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv'
> collect2: error: ld returned 1 exit status
> Error: linker exited with status 1
> ```

Use ``-allinst``, that is a template emission bug.
February 08
https://issues.dlang.org/show_bug.cgi?id=20802
February 07

On Wednesday, 7 February 2024 at 11:49:20 UTC, Richard (Rikki) Andrew Cattermole wrote:

> >
undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1

Use -allinst, that is a template emission bug.

!
Thanks, at least I can continue now, though presumably the cure has its own problems.

$ dmd --help | grep allinst
  -allinst          generate code for all template instantiations

Unclear exactly how -allinst does this, given type parameters, and it will affect all of the many templates I use in source with CodepointSet.

Can you shed any light?

February 08
On 08/02/2024 5:36 AM, Carl Sturtivant wrote:
> On Wednesday, 7 February 2024 at 11:49:20 UTC, Richard (Rikki) Andrew Cattermole wrote:
>>> ```
>>> undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv'
>>> collect2: error: ld returned 1 exit status
>>> Error: linker exited with status 1
>>> ```
>>
>> Use ``-allinst``, that is a template emission bug.
> 
> !
> Thanks, at least I can continue now, though presumably the cure has its own problems.
> 
> ```
> $ dmd --help | grep allinst
>    -allinst          generate code for all template instantiations
> ```
> Unclear exactly how -allinst does this, given type parameters, and it will affect all of the many templates I use in source with CodepointSet.
> 
> Can you shed any light?

Basically the compiler will by default try to elide templates it thinks isn't used.

However it doesn't always get this right, which this flag overrides by turning it off.
February 07
On Thu, Feb 08, 2024 at 05:44:59AM +1300, Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn wrote:
> On 08/02/2024 5:36 AM, Carl Sturtivant wrote:
[...]
> > ```
> > $ dmd --help | grep allinst
> >    -allinst          generate code for all template instantiations
> > ```
> > Unclear exactly how -allinst does this, given type parameters, and
> > it will affect all of the many templates I use in source with
> > CodepointSet.
> > 
> > Can you shed any light?
> 
> Basically the compiler will by default try to elide templates it thinks isn't used.
> 
> However it doesn't always get this right, which this flag overrides by turning it off.

Do we know why the compiler isn't getting it right?  Shouldn't we be fixing it instead of just turning off elision completely?


T

-- 
Let's call it an accidental feature. -- Larry Wall
February 08
On 08/02/2024 6:11 AM, H. S. Teoh wrote:
> Do we know why the compiler isn't getting it right?  Shouldn't we be
> fixing it instead of just turning off elision completely?

Of course we should.

It has been reported multiple times, with different examples trigger the switch symbol error.
February 08
On Wednesday, 7 February 2024 at 17:11:30 UTC, H. S. Teoh wrote:
> Do we know why the compiler isn't getting it right?  Shouldn't we be fixing it instead of just turning off elision completely?

This matter seems to have been an issue for some time.
https://forum.dlang.org/post/l5e5hm$1177$1@digitalmars.com

February 08
On Thu, Feb 08, 2024 at 06:22:29PM +0000, Carl Sturtivant via Digitalmars-d-learn wrote:
> On Wednesday, 7 February 2024 at 17:11:30 UTC, H. S. Teoh wrote:
> > Do we know why the compiler isn't getting it right?  Shouldn't we be fixing it instead of just turning off elision completely?
> 
> This matter seems to have been an issue for some time. https://forum.dlang.org/post/l5e5hm$1177$1@digitalmars.com

11 years and we still haven't fixed all the problems?!  That's ... wow.

I've recently run into the same problem myself and had to use -allinst in order to to compile my project.  Maybe I should dustmite it and submit a report. But given it's been 11 years, I'm not sure if this is worth my time....


T

-- 
"No, John.  I want formats that are actually useful, rather than over-featured megaliths that address all questions by piling on ridiculous internal links in forms which are hideously over-complex." -- Simon St. Laurent on xml-dev
February 09

On Thursday, 8 February 2024 at 18:43:09 UTC, H. S. Teoh wrote:

>

11 years and we still haven't fixed all the problems?! That's ... wow.

Incredible! Seems like D is experiencing featuritis.
Priorities may be wrong.

Instead of bug fixing and stabilization, people concentrate on
getting new stuff like ˋ:blubˋ into the language.

It‘s interesting to see this. But it‘s not positive to watch this.
The featuritis is just creating chaos, not a stable programming language you can count on.

« First   ‹ Prev
1 2