GNOME Bugzilla – Bug 559971
a compound line of code with a function that might throw followed by a conditional throw does not work
Last modified: 2009-01-17 23:17:59 UTC
Please describe the problem: if I have a function called foo that may throw then: int b = foo(); int a = 5/b; if (-1 < 1) throw new dee.CODE_1A("Error #2"); works as expected. However: int a = 5/foo(); if (-1 < 1) throw new dee.CODE_1A("Error #2"); does not work as expected. Steps to reproduce: compile and run this code: ------------------------- using GLib; errordomain dee { CODE_1A; } int foo() throws dee { if (-1 < 1) throw new dee.CODE_1A("Foo"); return 7; } int main (string[] args) { try { stdout.printf("Ok, got here\n"); int b = foo(); int a = 5/b; if (-1 < 1) throw new dee.CODE_1A("Error #2"); stdout.printf("Ok, but not here\n"); } catch (Error ex) { stdout.printf("Ex: %s\n",ex.message); } try { stdout.printf("Ok, got here\n"); int a = 5/foo(); if (-1 < 1) throw new dee.CODE_1A("Error #2"); stdout.printf("Ok, but not here\n"); } catch (Error ex) { stdout.printf("Ex: %s\n",ex.message); } return 0; } Actual results: Ok, got here Ex: Foo Ok, got here Floating point exception Expected results: Ok, got here Ex: Foo Ok, got here Ex: Foo Does this happen every time? Yes. Other information: I've found a couple other catch/throw vala compiler oddities as well. throw 1; // compiled by vala without any trouble but causes a Segmentation fault when run. Multiple catches are compiled by vala with no error, but generate bad C code that can't be compiled.
Thanks for taking the time to report this bug. This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed. It should be solved in the next software version. You may want to check for a software upgrade. *** This bug has been marked as a duplicate of 475922 ***