D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9913 - static if (__traits(compiles)...) causes program to hang
Summary: static if (__traits(compiles)...) causes program to hang
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-09 13:37 UTC by callumenator
Modified: 2021-01-24 05:20 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description callumenator 2013-04-09 13:37:49 UTC
DMD 2.062 Win32

import std.stdio, std.typecons;

void main()
{
    int ee = 0;
    static if (__traits(compiles, { Unique!int(&ee);}))
       auto e = Unique!int(&ee);
    writeln(e); // required to trigger
}

With the static if conditional (which passes) the writeln line causes the program to hang indefinitely after printing the expected result. Remove the static if conditional, and the program does not hang, behaves correctly.
Comment 1 callumenator 2013-06-10 17:03:04 UTC
(In reply to comment #0)

Still present in 2.063 (Win32).
Comment 2 Walter Bright 2013-10-07 00:08:19 UTC
Not an ice, as dmd itself does not hang. The compiled program does. Removed ice keyword.
Comment 3 yebblies 2013-11-22 07:29:20 UTC
Looks like an infinite look inside the gc
Comment 4 yebblies 2013-11-22 07:37:36 UTC
loop*
Comment 5 mhh 2021-01-24 05:20:02 UTC
Given example does not compile, an alternative version without Unique does not exhibit specified behaviour (Works since 2.067.old)