Bug 12710 – Bad @nogc requirement for Windows callbacks
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-05-06T10:57:00Z
Last change time
2014-06-15T07:13:37Z
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2014-05-06T10:57:01Z
////////////////////// test.d /////////////////////
import core.sys.windows.windows;
extern(Windows)
LRESULT wndProc(HWND, UINT, WPARAM, LPARAM) nothrow
{
return 0;
}
void main()
{
WNDCLASSW c;
c.lpfnWndProc = &wndProc;
RegisterClassW(&c);
}
///////////////////////////////////////////////////
The above no longer compiles. For some reason lpfnWndProc is now required to be @nogc, which makes no sense, as the callback is called from within the same thread and is allowed to interact freely with the GC.
A cast is now required, which is not very safe since the cast may subtly allow an incorrect callback signature or calling convention.
Comment #1 by dlang-bugzilla — 2014-05-06T10:59:20Z
I've also stumbled over similar cases for EnumWindows() and signal(). The pull
seems to confirm my experience with just popping "attribute:" at the start of a
file - that almost never really works.
Comment #3 by github-bugzilla — 2014-06-15T07:13:36Z