www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20234] New: Make!T (and likely emplace!T) do not work for

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

          Issue ID: 20234
           Summary: Make!T (and likely emplace!T) do not work for some
                    shared types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: htvennik gmail.com

Created attachment 1760
  --> https://issues.dlang.org/attachment.cgi?id=1760&action=edit
Patch fixing this issue

This is like a special case of Issue 20046, caused by a wrong instantiation of
emplaceRef. I spent days trying to find a minimal test case, but no success.

The error can easily be reproduced with a unittest build of
https://github.com/thaven/OneFile

(This issue is currently blocking a first release of that package)

The unittest build will produce output like:

----

$ dub test -f
Generating test runner configuration 'onefile-test-library' for 'library'
(library).
Performing "unittest" build using /usr/bin/dmd for x86_64.
onefile ~master: building configuration "onefile-test-library"...
/usr/include/dmd/phobos/std/conv.d(4419,19): Error: function
core.stdc.string.memcpy(return void* s1, scope const(void*) s2, ulong n) is not
callable using argument types (shared(Root)*, immutable(Root)*, ulong)
/usr/include/dmd/phobos/std/conv.d(4419,19):        cannot pass argument &chunk
of type shared(Root)* to parameter return void* s1
/usr/include/dmd/phobos/std/conv.d(4339,27): Error: template instance
std.conv.emplaceInitializer!(shared(Root)) error instantiating
/usr/include/dmd/phobos/std/experimental/allocator/package.d(1178,29):       
instantiated from here: emplaceRef!(shared(Root), shared(Root))
source/onefile/stm.d(1218,39):        instantiated from here:
make!(shared(Root), shared(AlignedMallocator))
source/onefile/container/slist.d(223,40):        instantiated from here:
tmMake!(shared(Root))
source/onefile/container/slist.d(675,18):        instantiated from here:
SList!uint
/usr/include/dmd/phobos/std/experimental/allocator/package.d(1190,53): Error:
forward reference to inferred return type of function call function ()  trusted
{
alloc.deallocate(m);
}
()
<...snip...>

----

The attached patch to Phobos fixes the problem. (Also to be found at
https://github.com/dlang/phobos/compare/master...thaven:fix/make-emplace-shared)

Any help finding the exact trigger for the bug, and thus a minimal test case,
is appreciated.

--
Sep 21 2019