Bug 8795 – mixing in "switch" or "interface;" makes dmd segfault

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-10T12:46:00Z
Last change time
2013-08-30T02:42:37Z
Keywords
ice, pull
Assigned to
nobody
Creator
nilsbossung

Comments

Comment #0 by nilsbossung — 2012-10-10T12:46:49Z
A) mixing in "switch" --- cat > test.d <<code void s() {mixin("switch");} code dmd -c -o- test.d --- test.d(1): Error: found 'EOF' when expecting '(' test.d(1): Error: expression expected, not 'EOF' test.d(1): Error: found 'EOF' when expecting ')' test.d(1): Error: found 'EOF' instead of statement Segmentation fault (core dumped) --- B) mixing in "interface;" --- cat > test.d <<code mixin("interface;"); code dmd -c -o- test.d --- test.d(1): Error: anonymous classes not allowed Segmentation fault (core dumped) ---
Comment #1 by hsteoh — 2013-08-28T22:32:53Z
In (A), the segfault is happening in SwitchStatement::semantic(Scope*) [statement.c:3101], from attempting to dereference a null pointer (body = body->semantic(sc); where body==NULL). Looks like the body is null because it was an invalid switch mixin, but for some reason the compiler didn't catch the syntax error and proceeded to create a SwitchStatement with a NULL body.
Comment #2 by hsteoh — 2013-08-29T08:02:05Z
Comment #3 by github-bugzilla — 2013-08-30T02:42:22Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2d0de85d28e1d953f7590ea6888bc6a12c25bd35 Merge pull request #2504 from quickfur/issue8795 Fix issue 8795: segfault on mixin("switch") and mixin("interface;")