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
Comment #2 by sludwig — 2014-06-09T12:54:51Z
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
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/ca534703cfefeb9ba5cdac8f901e9d9451dd0356 fix Issue 12710 - Bad @nogc requirement for Windows callbacks https://github.com/D-Programming-Language/druntime/commit/9ffa960a05b235797001c9ec0ed0dbe0230a9286 Merge pull request #843 from 9rnsr/fix12710 Issue 12710 - Bad @nogc requirement for Windows callbacks