Bug 1067 – release flag kills Win32 applications without unittest flag?
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-03-18T01:50:00Z
Last change time
2014-02-16T15:21:20Z
Assigned to
bugzilla
Creator
rpgfan3233
Comments
Comment #0 by rpgfan3233 — 2007-03-18T01:50:10Z
I've tried creating a simple window using CreateWindowA() from the Win32 API. When I compile without the release switch (-release), everything runs fine. I add the unittest (-unittest) switch and the program still runs fine. However, if you don't include the unittest switch and you DO include the release switch, the window is not displayed, and runs in the background. I tried compiling with warnings on as well. No warnings were generated.
dmd mywin gdi32.lib mywin.def ;OK
dmd mywin gdi32.lib mywin.def -unittest ;OK
dmd mywin gdi32.lib mywin.def -release ;NOT OK
dmd mywin gdi32.lib mywin.def -release -w ;NOT OK with no warnings displayed
dmd mywin gdi32.lib mywin.def -release -unittest ;OK
I ended up going into the dmd\samples\d directory and compiling the winsamp.d file the same way I tried compiling mine. The results were the same, other than the fact that using the -w flag, I found that there was no default case for the nested switch statement in "case WM_COMMAND" in winsamp.d::WindowProc - "switch (LOWORD(wParam))". I added a default case, and it then compiled without warnings.
Is this the way the release switch is supposed to work? Unit tests aren't required, are they?
Comment #1 by rpgfan3233 — 2007-03-18T01:54:24Z
Also, this happened on 1.007, which I had at the time. I upgraded to 1.009 hoping that would resolve the issue. It didn't, obviously.
Comment #2 by torhu — 2007-03-18T12:44:29Z
Line 78 in winsamp.d:
assert(RegisterClassA(&wc));
Moving 'RegisterClassA(&wc);' out of the assert fixes the problem.
-release removes assert, while -unittest adds them back in. Your test app probably has the same kind of bug. An app can't rely on code in asserts, because that code isn't included when compiling in release mode.