Consensus on goto's into catch blocks

monarch_dodra monarchdodra at gmail.com
Thu Jun 13 12:11:27 PDT 2013


On Thursday, 13 June 2013 at 19:08:40 UTC, monarch_dodra wrote:
> On Thursday, 13 June 2013 at 18:51:01 UTC, Brad Roberts wrote:
>> On 6/13/13 10:35 AM, Iain Buclaw wrote:
>>
>> I think it should be illegal, but not because it's a catch 
>> block but because of the initialization.
>> If the catch was just "catch (Exception)" then it shouldn't be 
>> illegal.
>
> Again for what it's worth, the C++ program with "catch(...)" 
> also fails.

And for "catch(int)", this is interesting, it produces:
main.cpp||In function 'int main()':|
main.cpp|8|error: jump to label 'L2' [-fpermissive]|
main.cpp|3|error:   from here [-fpermissive]|
main.cpp|7|error:   crosses initialization of 'int <anonymous>'|
main.cpp|8|error:   enters catch block|

So yeah, just crossing a declaration, even anonymous, is enough 
for illegality in C++, hence simply no way to jump to inside a 
catch block.


More information about the Digitalmars-d mailing list