Bug 13424 – [REG2.066] Initialization of delegate to do-nothing default causes segfault at runtime

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-04T23:03:00Z
Last change time
2014-09-07T11:05:24Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2014-09-04T23:03:21Z
I have a struct of delegates that I'd like to default to do-nothing stubs: ------ struct S { void delegate(dchar ch) onChar = (dchar) {}; ... /* other delegate variables similarly initialized */ } ------ It compiles, but crashes at runtime. Looking at the assembly code, it appears to be attempting to call an invalid pointer.
Comment #1 by czdanol — 2014-09-04T23:05:01Z
Please provide some test-case code example. :)
Comment #2 by hsteoh — 2014-09-05T16:16:19Z
Ah, sorry, forgot to post complete example. Here it is: ------ struct S { void delegate(dchar) onChar = (dchar) {}; } void main() { S s; s.onChar('a'); } ------
Comment #3 by czdanol — 2014-09-05T20:26:46Z
What compiler are you using? http://dpaste.dzfl.pl/9f8f1dc801cd I have tried 2.065 and 2.066 and it doesn't compile.
Comment #4 by hsteoh — 2014-09-05T21:28:12Z
git HEAD. Could it be a regression?
Comment #5 by hsteoh — 2014-09-05T21:38:53Z
Strange, I just checked out v2.066.0 and it still compiles and gives me the segfault. Could it be a platform-specific bug?? I'm testing on Linux/64-bit. Or maybe the tag isn't actually what was released? I'm confused.
Comment #6 by czdanol — 2014-09-05T21:51:22Z
Hmm, I tried it again under 2.066 and it now does the same thing as for you. I must have missed something last time checking. Looks like a bug :)
Comment #7 by hsteoh — 2014-09-05T22:47:35Z
Seems the compile error was removed by this commit: 180a6aabbb5d5db72e6650f8cedc4ba4b7899017 (https://github.com/D-Programming-Language/dmd/pull/2824). Not sure if this is a regression, or a new bug introduced by the PR.
Comment #8 by k.hara.pg — 2014-09-06T02:07:58Z
(In reply to hsteoh from comment #7) > Seems the compile error was removed by this commit: > 180a6aabbb5d5db72e6650f8cedc4ba4b7899017 > (https://github.com/D-Programming-Language/dmd/pull/2824). Not sure if this > is a regression, or a new bug introduced by the PR. This is a regression issue introduced in the commit. https://github.com/D-Programming-Language/dmd/pull/3951
Comment #9 by github-bugzilla — 2014-09-07T06:26:55Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c3026fe5d2381b86368b3fb9f8d8e2343cb3f82b fix Issue 13424 - Initialization of delegate to do-nothing default causes segfault at runtime https://github.com/D-Programming-Language/dmd/commit/18d5bd9d1dc5f06dbccfc1c56af740fe394a19ff Merge pull request #3951 from 9rnsr/fix13424 [REG2.066] Issue 13424 - Initialization of delegate to do-nothing default causes segfault at runtime
Comment #10 by github-bugzilla — 2014-09-07T11:05:24Z
Commit pushed to 2.066 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/863f5a55e4794fd3cf45f1c96d941654e4075258 Merge pull request #3951 from 9rnsr/fix13424 [REG2.066] Issue 13424 - Initialization of delegate to do-nothing default causes segfault at runtime