http://d.puremagic.com/issues/show_bug.cgi?id=9028
Summary: `main` is trated sometimes as having C linkage and
sometimes as having D linkage
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Denis Shelomovskij <[email protected]> 2012-11-15
11:59:34 MSK ---
---
void main(string[] args)
{
if(!args.length) return;
foreach(i; 0 .. 1)
main(null); // ok, C linkage used
foreach(i; 0 .. 1)
(&main)(null); // also ok
foreach(i; 0 .. 1)
{
auto p = &main; // D linkage used
p(null); // stack corruption, results in Access Violation
//asm { add ESP, 0x8; } // uncomment to fix
}
}
---
Note: do not mark `main` as `extern(C)` because it will lead to not calling
runtime initialization stuff.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------