Issue 20234 - Make!T (and likely emplace!T) do not work for some shared types
Summary: Make!T (and likely emplace!T) do not work for some shared types
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-21 10:03 UTC by Harry Vennik
Modified: 2024-12-01 16:35 UTC (History)
0 users

See Also:


Attachments
Patch fixing this issue (1.87 KB, patch)
2019-09-21 10:03 UTC, Harry Vennik
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Harry Vennik 2019-09-21 10:03:47 UTC
Created attachment 1760 [details]
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.
Comment 1 Harry Vennik 2020-02-15 10:02:18 UTC
Comment on attachment 1760 [details]
Patch fixing this issue

The patch is incorrect. Don't know how it could even work for my project, as it effectively removes qualifiers from the return type of make!T.
Comment 2 dlangBugzillaToGithub 2024-12-01 16:35:38 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10388

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB