[Issue 17504] New: Passing templated varargs to array varargs base class constructor segfaults
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jun 14 09:12:50 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17504
Issue ID: 17504
Summary: Passing templated varargs to array varargs base class
constructor segfaults
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: nanayamae at gmail.com
Created attachment 1649
--> https://issues.dlang.org/attachment.cgi?id=1649&action=edit
Reduction of the segfault
I have a templated wrapper class (TC) that inherits from its template argument.
The base class's (BC) constructor arguments are unknown, therefore the
constructor of TC is templated with
this(Args...)(MyType wrappedObj, Args args)
{
super(args);
}
and calls its base constructor using args.
When the base constructor has varargs
this(MyType[] objs...)
{
_objs = objs;
}
and TC's templated constructor is called using varargs
auto tc = new TC(wrappedObj, obj1, obj2); // segfaults
any attempt at accessing the objects in _objs by iterating (std.algorithm or
foreach) segfaults (see attachment). Calling _objs[0] and accessing its members
is ok.
A workaround is passing in an array instead of varargs, therefore marked as
minor.
auto tc = new TC(wrappedObj, [obj1, obj2]); // ok
The full code is in attachment.
(Please forgive me if I mixed up a bit of terminology.)
--
More information about the Digitalmars-d-bugs
mailing list