Affichage des articles dont le libellé est Label. Afficher tous les articles
Affichage des articles dont le libellé est Label. Afficher tous les articles

mardi 28 janvier 2014

Re: goto label inside of if statement topic




Vir Campestris <(E-Mail Removed)> wrote in
news:(E-Mail Removed) o.uk:

> On 26/01/2014 21:32, Gareth Owen wrote:
>> Take Paavo's advice and memorise it.
>>
>> You'll not find it a better argument more cogently stated.
>> If you remember nothing else, remember the first sentence.

>
> I'll second that - but add a bit of data.
>
> I've been writing C since before some of my co-workers were born (yes,
> it scares me too!) and I've only written ONE goto ever.
>
> And that didn't make it to checkin...
>
> They do have a place, but it's vanishingly rare. I think the place is
> not in a C++ program.
>
> Andy


Andy.... you make me pause for thought. If I understand the implication of
what you wrote, then it means I haven't learned my first *real* C++
command!

--
Jax





jeudi 23 janvier 2014

goto label inside of if statement topic




On 1/23/2014 2:32 PM, W Karas wrote:
> I was surprised to find that this code:
>
> struct A { A(); ~A(); };
>
> void bar();
>
> void foo(bool f)
> {
> if (0)
> {
> LAB: ;
> }
> else
> {
> A a;
>
> if (f) goto LAB;
>
> bar();
> }
> }
>
> will compile without warnings using GCC 4.7.3, even with -Wall and -Wextra .
>
> The point, in case you were wondering, would be a macro-based "named block" pseudo-construct, where the block could be exited from any depth of block nesting, for example:
>
> #define BLOCK(NAME) if (0) { NAME: ; } else
> #define EXITBLOCK(NAME) goto NAME;
>
> struct A { A(); ~A(); };
>
> void bar();
>
> void foo(bool f)
> {
> BLOCK(XYZ)
> {
> A a;
>
> if (f) EXITBLOCK(XYZ)
>
> bar();
> }
> }
>


And it actually skips the 'else' part when jumping into the 'if'
section, yes? And how well do optimizers handle it?

V
--
I do not respond to top-posted replies, please don't ask