Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #86922

Re: creating a new local variable after a goto

Path csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c++
Subject Re: creating a new local variable after a goto
Date Thu, 13 Oct 2022 12:23:30 +0100
Organization A noiseless patient Spider
Lines 32
Message-ID <87mta0j7bh.fsf@bsb.me.uk> (permalink)
References <ti7u75$1n58g$1@dont-email.me> <87zge0jumy.fsf@bsb.me.uk> <ti7v7i$1n6fh$2@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Info reader01.eternal-september.org; posting-host="ebee1d994c259e3ec935394f7e8a10aa"; logging-data="1880844"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RBCyqH7/LNy/YKe4T78ycX9SNJsvoMic="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock sha1:n6xru2FqT5nHiROgSLwyLUpUIik= sha1:NOt/vZzsqXn5K2maWbVyKtDIZZw=
X-BSB-Auth 1.77be3fbdc0055c76fac6.20221013122330BST.87mta0j7bh.fsf@bsb.me.uk
Xref csiph.com comp.lang.c++:86922

Show key headers only | View raw


Andrey Tarasevich <andreytarasevich@hotmail.com> writes:

> On 10/12/2022 7:59 PM, Ben Bacarisse wrote:
>> Lynn McGuire <lynnmcguire5@gmail.com> writes:
>> 
>>> 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 ?
>> You can't have a goto and a matching label that might skip over an
>> initialisation.  The same applies to non-constructed POD types too.
>
> It is not about "construction", it is about initialization.

Hmm... I thought I said that.  Sorry if was not clear.

> So called vacuous initialization can be bypassed. I.e. it does NOT
> apply to a "non-constructed POD" object declared without an
> initializer.

The second sentence was not intended to be read with the first.

-- 
Ben.

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web