Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #86898 > unrolled thread
| Started by | Lynn McGuire <lynnmcguire5@gmail.com> |
|---|---|
| First post | 2022-10-12 21:47 -0500 |
| Last post | 2022-10-13 21:55 -0500 |
| Articles | 1 on this page of 21 — 11 participants |
Back to article view | Back to comp.lang.c++
creating a new local variable after a goto Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-12 21:47 -0500
Re: creating a new local variable after a goto Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-10-13 03:59 +0100
Re: creating a new local variable after a goto Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-10-12 20:04 -0700
Re: creating a new local variable after a goto Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-10-13 12:23 +0100
Re: creating a new local variable after a goto Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-13 21:56 -0500
Re: creating a new local variable after a goto "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-13 20:11 -0700
Re: creating a new local variable after a goto Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-13 22:45 -0500
Re: creating a new local variable after a goto "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-13 20:54 -0700
Re: creating a new local variable after a goto "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-13 20:55 -0700
Re: creating a new local variable after a goto Gawr Gura <gawrgura@mail.hololive.com> - 2022-10-14 04:41 +0000
Re: creating a new local variable after a goto Ralf Fassel <ralfixx@gmx.de> - 2022-10-14 11:53 +0200
Re: creating a new local variable after a goto scott@slp53.sl.home (Scott Lurndal) - 2022-10-14 13:48 +0000
Re: creating a new local variable after a goto Richard Damon <Richard@Damon-Family.org> - 2022-10-14 13:38 -0400
Re: creating a new local variable after a goto scott@slp53.sl.home (Scott Lurndal) - 2022-10-14 17:53 +0000
Re: creating a new local variable after a goto Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-11-15 16:26 -0800
Re: creating a new local variable after a goto Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-11-15 17:05 -0800
Re: creating a new local variable after a goto Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-10-14 01:07 -0700
Re: creating a new local variable after a goto "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-14 14:32 -0700
Re: creating a new local variable after a goto Manfred <noname@add.invalid> - 2022-10-15 01:56 +0200
Re: creating a new local variable after a goto Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-10-12 19:59 -0700
Re: creating a new local variable after a goto Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-13 21:55 -0500
Page 2 of 2 — ← Prev page 1 [2]
| From | Lynn McGuire <lynnmcguire5@gmail.com> |
|---|---|
| Date | 2022-10-13 21:55 -0500 |
| Message-ID | <tiaj3n$20k7r$1@dont-email.me> |
| In reply to | #86900 |
On 10/12/2022 9:59 PM, Andrey Tarasevich wrote:
> On 10/12/2022 7:47 PM, Lynn McGuire wrote:
>> So, I created a new local variable after a goto:
>>
>> if (crashed)
>> goto L99999;
>>
>> std::string msg;
>>
>> Visual C++ 2015 then informed me that "initialization of 'msg' is
>> skipped by 'goto L99999'".
>>
>> Is this a real thing, no variable with a constructor can be created
>> after a goto ?
>>
>
> Firstly, it is not about its being "after a goto". It is about jumping
> into the scope of the variable bypassing its initialization. So, it
> mostly depends on where 'L99999' is located, not on where 'goto' is
> located.
>
> You can reproduce the same error "before goto":
>
> {
> std::string msg;
> skip:;
> }
>
> goto skip;
>
> Secondly, yes, it is a real thing for variables with automatic storage
> duration. There's no such restriction for variables with static storage
> duration though. So, you can actually bypass its construction
>
> goto skip;
> static std::string msg;
> skip:;
>
> At 'skip' you will see non-constructed (and therefore unusable) 'msg'.
Thanks !
Lynn
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.c++
csiph-web