1731 – forward reference of function type alias resets calling convention

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1731 - forward reference of function type alias resets calling convention
Summary: forward reference of function type alias resets calling convention
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 critical
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks: 340 2573
Show dependency tree / graph
Reported: 2007年12月14日 19:28 UTC by Vladimir Panteleev
Modified: 2014年02月24日 15:33 UTC (History)
2 users (show)

See Also:


Attachments
evaluate forward referenced alias in correct scope (1.45 KB, patch)
2009年09月23日 14:03 UTC, Rainer Schuetze
Details | Diff
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2007年12月14日 19:28:44 UTC
// == minimal testcase start ==
alias uint DWORD;
MY_API_FUNCTION lpStartAddress; // <-- comment this line to remove error
extern (Windows) alias DWORD function(void*) MY_API_FUNCTION;
static assert(MY_API_FUNCTION.stringof == "uint(Windows *)(void*)");
// == minimal testcase end ==
The actual calling convention (MY_API_FUNCTION.stringof) is "uint(*)(void*)".
This is from a real-life case (the Windows header project).
Comment 1 anonymous4 2009年04月06日 06:05:43 UTC
For dmd 2.023
alias uint DWORD;
MY_API_FUNCTION lpStartAddress; // <-- comment this line to remove error
extern (Windows) alias DWORD function(void*) MY_API_FUNCTION;
static assert(MY_API_FUNCTION.stringof == "uintWindows function(void*)", MY_API_FUNCTION.stringof);
Comment 2 anonymous4 2009年04月06日 06:10:18 UTC
Subtle and disastrous bug, raising severity.
Comment 3 Rainer Schuetze 2009年09月23日 14:03:37 UTC
Created attachment 465 [details] 
evaluate forward referenced alias in correct scope
The forward reference to the alias causes its semantic analysis to be run from the scope of the variable declaration, omitting the "extern(Windows)" attribute. The patch uses the scope of the symbol (which happens to already exist) instead of the current scope.
The patch also fixes the bad spacing "uintWindows".
Comment 4 Rainer Schuetze 2009年09月23日 14:04:11 UTC
the patch is against dmd 2.032
Comment 5 Don 2009年09月24日 00:23:59 UTC
You're a legend! This was on my list of ten most worst bugs in DMD.
Comment 6 Walter Bright 2009年10月06日 02:13:17 UTC
Fixed dmd 1.048 and 2.033


AltStyle によって変換されたページ (->オリジナル) /