Consensus on goto's into catch blocks
monarch_dodra
monarchdodra at gmail.com
Thu Jun 13 14:08:07 PDT 2013
On Thursday, 13 June 2013 at 20:40:27 UTC, Iain Buclaw wrote:
> On 13 June 2013 20:18, H. S. Teoh <hsteoh at quickfur.ath.cx>
> wrote:
>> On Thu, Jun 13, 2013 at 11:50:49AM -0700, Brad Roberts 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.
>>
>> Why shouldn't it be illegal, though? I honestly don't see any
>> use case
>> for such a strange construct. Not to mention, like
>> monarch_dodra said,
>> if the anonymous Exception's reference is on the stack, then
>> at the end
>> of the catch block there'd be code to adjust the stack
>> pointer, which
>> will trash your stack pointer horribly if we goto the middle
>> of the
>> block bypassing the stack allocation of the Exception
>> reference.
>>
>
> Thank goodness D's exceptions are all heap allocated!
>
> --
> Iain Buclaw
>
> *(p < e ? p++ : p) = (c & 0x0f) + '0';
Irrelevant no? You're still throwing around your pointer, which
takes its stack space.
Well, I guess as long as the compiler (optionally) supports
skipping over initialization it means it can handle the magic
required to maintain the stack pointer, so that shouldn't really
be a problem.
More information about the Digitalmars-d
mailing list