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


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

Re: creating a new local variable after a goto

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c++
Subject Re: creating a new local variable after a goto
Date 2022-10-13 03:59 +0100
Organization A noiseless patient Spider
Message-ID <87zge0jumy.fsf@bsb.me.uk> (permalink)
References <ti7u75$1n58g$1@dont-email.me>

Show all headers | View raw


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.

-- 
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