GNOME Bugzilla – Bug 626397
Incorrect enum / switch usage causing segfault in 0.9.4 (and previous)
Last modified: 2010-08-20 07:53:42 UTC
This came up because of a stupid error in my code but, incorrect (i.e. stupid!) use of an enum in a switch statement is segfaulting the code generator on both 64bit x86 and armel platforms. As I say it's clearly stupid on behalf of the programmer but it should not compile rather than segfault I guess. Below is the smallest example I could devise that exhibits the segfault in 0.9.4, but the behaviour is consistent as complexity grows. public static int main(string[] args) { Test test = {TheEnumerator.ONE}; switch (TheEnumerator) { // clearly should be test.the_enumerator ! case TheEnumerator.ONE: break; default: break; } return 0; } public enum TheEnumerator { ONE } public struct Test { TheEnumerator the_enumerator; }
Created attachment 167538 [details] [review] Patch to fix the issue Attached patch fixes the issue. Just a missing null check.
commit 3b68bb5b88006a5a2a704b593e9b9e7e878da8db Author: Carlo Teubner <carlo.teubner@gmail.com> Date: Fri Aug 20 09:52:25 2010 +0200 Fix crash on invalid switch expression Fixes bug 626397.