D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17987 - Cannot use string in Variant at compile time
Summary: Cannot use string in Variant at compile time
Status: RESOLVED DUPLICATE of issue 11864
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-17 12:21 UTC by Jonathan M Davis
Modified: 2020-06-13 19:34 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jonathan M Davis 2017-11-17 12:21:27 UTC
This code

==========
import std.variant;

Variant v = "hello";

void main()
{
}
==========

results in this error:

/usr/local/include/dmd/std/variant.d(624): Error: memcpy cannot be interpreted at compile time, because it has no available source code
/usr/local/include/dmd/std/variant.d(559):        called from here: this.opAssign(value)
q.d(3):        called from here: VariantN(& handler, cast(ubyte)0u, ).this("hello")

I would _think_ that it could be made to work without memcpy, but I don't know. Regardless, the use of memcpy restricts the ability to use Variant at compile time. So ideally, Variant would be fixed so that the example here worked.
Comment 1 Paul Backus 2020-06-13 19:34:16 UTC

*** This issue has been marked as a duplicate of issue 11864 ***