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


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

Re: MSVC-bug

From Andrey Tarasevich <andreytarasevich@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: MSVC-bug
Date 2024-03-02 12:38 -0800
Organization A noiseless patient Spider
Message-ID <us02nk$22aa3$1@dont-email.me> (permalink)
References (4 earlier) <uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org> <urrmgq$12lh3$1@dont-email.me> <ursmlf$18r2d$1@raubtier-asyl.eternal-september.org> <uru3ps$1i8fc$1@dont-email.me> <uruhca$1ocbb$1@raubtier-asyl.eternal-september.org>

Show all headers | View raw


On 03/01/24 10:36 PM, Bonita Montero wrote:
> Am 02.03.2024 um 03:44 schrieb Andrey Tarasevich:
>> On 03/01/24 5:53 AM, Bonita Montero wrote:
>>>>
>>>> You have been told very clearly already that in this case 
>>>> `std::function<>` does not perform any memory allocation in Visual 
>>>> Studio. Neither in Debug nor in Release builds. You imagined it.
>>>
>>> Not true ! This code prints "alloc" first with MSVC
>>> and a Debug-build, but not with Release-builds.
>>>
>> ???
>>
>> As you have already been told, your "alloc" originates from 
>> `std::string`, ...
> 
> No, from the function allocation. Just single-step the code yourself.

... which is exactly what I did in the first place.

Once again: the Debug config of the _original_ version of the code emits 
two allocations, both of which originate in `std::string`. The first one 
is allocation of some sort of "container proxy" in `std::string`s 
constructor. Another is the same thing in your `[str = str]`.

The updated version of the code (with '[&str]`) emits only one 
allocation: the same "container proxy" in `std::string`s constuctor.

No allocations are made for `std::function<>` in either version.

-- 
Best regards,
Andrey

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


Thread

MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-02-13 12:07 +0100
  Re: MSVC-bug Paavo Helde <eesnimi@osa.pri.ee> - 2024-02-15 15:34 +0200
    Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-02-15 12:20 +0100
      Re: MSVC-bug Paavo Helde <eesnimi@osa.pri.ee> - 2024-02-16 00:11 +0200
        Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-02-16 09:17 +0100
          Re: MSVC-bug Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-02-29 20:45 -0800
            Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-03-01 14:53 +0100
              Re: MSVC-bug Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-03-01 18:44 -0800
                Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-03-02 07:36 +0100
                Re: MSVC-bug Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-03-02 12:38 -0800

csiph-web