[Issue 16291] phobosinit never gets called (EncodingScheme.create fails)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 5 09:49:26 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16291

--- Comment #29 from github-bugzilla at puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/9d73d18c0cd4ecd1bb1ebc8bb01941f209570ca2
fix Issue 16291 - EncodingScheme.create fails

- add EncodingScheme.register overload that references the registered class
- just adding the FQN name of a class does not reference that class, so
  it must not end up in the binary and subsequently EncodingScheme.create
failed
- This used to work by chance b/c all the EncodingScheme implementations
  were in a module w/ static ctor. Any user of std.encoding did drag in
  that ModuleInfo, which in turn referenced all classes of std.encoding.
  Since moving the static ctor to std.internal.phobosinit to break a
  cycle, the classes were no longer referenced by a ModuleInfo w/ shared
  ctor, so they wouldn't end up in the binary unless explicitly
  referenced elsewhere.
- deprecate the old EncodingScheme.register(string fqn) b/c relying on
  Object.factory is slow, error prone (linkage), and really unnecessary
- import encodinginit in std.encoding so that the
  std_encoding_shared_static_this callback actually gets run

https://github.com/dlang/phobos/commit/ad739f232ea93f56b9f72920be49d999a2507652
Merge pull request #4840 from MartinNowak/fix16291

fix Issue 16291 - EncodingScheme.create fails

--


More information about the Digitalmars-d-bugs mailing list