www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.uni CodepointSet toString

reply Carl Sturtivant <sturtivant gmail.com> writes:
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_errorZQrFNa
bNiNfAyamZv]+0x19): undefined reference to
`_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
```
Feb 06
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
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_errorZQrFNa
bNiNfAyamZv]+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.
Feb 07
next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
https://issues.dlang.org/show_bug.cgi?id=20802
Feb 07
prev sibling parent reply Carl Sturtivant <sturtivant gmail.com> writes:
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?
Feb 07
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
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.
Feb 07
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
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
Feb 07
next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
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.
Feb 07
prev sibling parent reply Carl Sturtivant <sturtivant gmail.com> writes:
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
Feb 08
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
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
Feb 08
parent reply Danilo <codedan aol.com> writes:
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.
Feb 09
next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 09/02/2024 9:04 PM, Danilo wrote:
 Instead of bug fixing and stabilization, people concentrate on getting 
 new stuff like ˋ:blubˋ into the language.
Umm, I take it that you didn't know that one of the reasons we spent the past year focusing on bug fixing and stabilization is because of my work trying to get shared library support resolved? My focus is upon making D's foundations stable, and that work comes in many forms and yes some of that is in new features which help resolve other problems in the ecosystem. Whether it be getting D's identifiers able to express recent C versions and hence interoperability, making sure how we represent and work with symbols actually work without error in common situations or just fixing random bugs where something minor was messed up some place. They are all stabilization and bug fixing tasks that I have some thing to do with. People are doing what they can to make D better, and we are all aware for those of us who actively contribute that D has a very large backlog of bugs that need resolving.
Feb 09
prev sibling parent Paul Backus <snarwin gmail.com> writes:
On Friday, 9 February 2024 at 08:04:28 UTC, Danilo wrote:
 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.
If you look at the work actually being done in Github PRs, the vast majority of it is bug fixes and stabilization: https://github.com/dlang/dmd/pulls?q=is%3Apr+is%3Amerged https://github.com/dlang/phobos/pulls?q=is%3Apr+is%3Amerged However, new features are more exciting to talk about, so they get more attention on the forums.
Feb 12