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


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

Re: Why does this work in MSVC 2019...

From "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups comp.lang.c++
Subject Re: Why does this work in MSVC 2019...
Date 2021-05-18 20:06 -0700
Organization Aioe.org NNTP Server
Message-ID <s81vc4$16fq$1@gioia.aioe.org> (permalink)
References (2 earlier) <s80p1o$a0i$1@dont-email.me> <s81cr4$15eb$1@gioia.aioe.org> <s81jdl$272$1@dont-email.me> <s81jp6$1kfb$1@gioia.aioe.org> <f7503b30-9b74-4c22-a265-71db5e620f42n@googlegroups.com>

Show all headers | View raw


On 5/18/2021 5:55 PM, Öö Tiib wrote:
> On Wednesday, 19 May 2021 at 02:49:13 UTC+3, Chris M. Thomasson wrote:
>> On 5/18/2021 4:42 PM, Bonita Montero wrote:
>>>>>>> set_t::iterator const& search_id(unsigned long id) const
>>>>>>> {
>>>>>>> return m_set.find(id);
>>>>>>> }
>>>>>
>>>>> Totally brain-damaged.
>>>
>>>> :^)
>>>> I was just wondering why MSVC allows this to run in the first place.
>>>
>>> Why not ? It's not uncompilable code.
>> Well, warnings aside for a moment, it seems to compile, _and_ run on
>> MSVC, however it will not even run on GCC without a segfault. Plus, the
>> code has a bug. I get warnings in MSVC, but it still runs it to
>> completion. I was just wondering why.
> 
> The segfault indicates that  gcc allows it to run as well unless you mean
> that the compiler segfaults (that i've not seen gcc to do for ages).

Yes, GCC allows it to run with warnings, and segfaults, and does not 
allow the bugged program to run to completion.


> 
> MSVC did allow to take lvalue references to non const of temporaries (that
> should not compile) for quite long time. I have not checked if it has
> stopped it finally ... that may have something to do with different outcome
> of undefined behavior.

MSVC allows that now. It compiles the bugged code, spits out a couple of 
warnings, and lets the compiled program run to completion. Strange.


> 
> Undefined behavior is what it is ... different nasal demons or lack
> of such from repeated runs of same compiled binary with same
> data are rare but possible with MSVC and gcc alike.
> 

Big time.

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


Thread

Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-17 16:05 -0700
  Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-17 16:11 -0700
    Re: Why does this work in MSVC 2019... Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-05-17 23:24 +0000
  Re: Why does this work in MSVC 2019... "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2021-05-18 22:29 +0200
    Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-18 15:09 -0700
      Re: Why does this work in MSVC 2019... Christian Gollwitzer <auriocus@gmx.de> - 2021-05-19 07:57 +0200
        Re: Why does this work in MSVC 2019... James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-05-19 09:58 -0400
  Re: Why does this work in MSVC 2019... Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2021-05-18 17:01 +0100
    Re: Why does this work in MSVC 2019... Bonita Montero <Bonita.Montero@gmail.com> - 2021-05-18 18:12 +0200
      Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-18 14:50 -0700
        Re: Why does this work in MSVC 2019... Bonita Montero <Bonita.Montero@gmail.com> - 2021-05-19 01:42 +0200
          Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-18 16:48 -0700
            Re: Why does this work in MSVC 2019... Öö Tiib <ootiib@hot.ee> - 2021-05-18 17:55 -0700
              Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-18 20:06 -0700
                Re: Why does this work in MSVC 2019... Paavo Helde <myfirstname@osa.pri.ee> - 2021-05-19 09:50 +0300
                Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-19 00:45 -0700
            Re: Why does this work in MSVC 2019... Bonita Montero <Bonita.Montero@gmail.com> - 2021-05-19 07:02 +0200
              Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-19 00:46 -0700
      Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-18 15:10 -0700
    Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-18 14:59 -0700
  Re: Why does this work in MSVC 2019... Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-05-20 03:44 +0300
    Re: Why does this work in MSVC 2019... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-05-19 20:38 -0700

csiph-web