D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6801 - access violation when passing a function literal to the mixin and calling it from function that has other declarations
Summary: access violation when passing a function literal to the mixin and calling it ...
Status: RESOLVED DUPLICATE of issue 11545
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2011-10-10 03:01 UTC by luka8088
Modified: 2013-11-21 18:54 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description luka8088 2011-10-10 03:01:58 UTC
// this happens on Windows XP, 32bit, any version between dmd2-042 and dmd2-055
// there was also a feedback that linux dmd2-055 causes segfault

// workaround for this is to use -O when compiling (both or windows and linux)

import std.stdio;

mixin template tpl1 (alias fn) {
  
  void b () {
    // calling fn causes Access Violation if there is two or more int declarations
    // in order to make this work either remove one int declaration or remove fn call
    int c;
    int d;
    fn();
  }

}

class a {
  mixin tpl1!(function () { writeln("test"); });
}

void main () {
  a a1 = new a();
  a1.b();
}
Comment 1 SomeDude 2012-05-01 15:17:39 UTC
Also fails with 2.059 Win32
Comment 2 Kenji Hara 2013-11-21 18:54:05 UTC

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