Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The solution to a problem changes the nature of the problem. -- Peer


devel / comp.lang.c++ / MSVC-bug

SubjectAuthor
* MSVC-bugBonita Montero
`* Re: MSVC-bugPaavo Helde
 `* Re: MSVC-bugBonita Montero
  `* Re: MSVC-bugPaavo Helde
   `* Re: MSVC-bugBonita Montero
    `* Re: MSVC-bugAndrey Tarasevich
     `* Re: MSVC-bugBonita Montero
      `* Re: MSVC-bugAndrey Tarasevich
       `* Re: MSVC-bugBonita Montero
        `- Re: MSVC-bugAndrey Tarasevich

1
MSVC-bug

<uqfih1$22741$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3147&group=comp.lang.c%2B%2B#3147

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: MSVC-bug
Date: Tue, 13 Feb 2024 12:07:14 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 13 Feb 2024 11:07:13 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="7b36bd74df4b35909f14ed1882a726d1";
logging-data="2169985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193j4xx+kwjfn22RLo+SE/zgHkXa66mU9U="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UlersTrSN0BFoti7H9KTCczI1Po=
Content-Language: de-DE
 by: Bonita Montero - Tue, 13 Feb 2024 11:07 UTC

If you initialize a function<>-object with a reference_wrapper it
is guaranteed that the function<>-object references an external
function-object without any memory allocation. libstdc++ and libc++
don't allocate any memory with such function<>-objects according
to the standard, but MSVC does allocate external memory.

#include <iostream>
#include <functional>

using namespace std;

void *operator new( size_t n )
{ cout << "alloc" << endl;
void *p = malloc( n );
if( !p )
throw bad_alloc();
return p;
}

void operator delete( void *p )
{ free( p );
}

int main()
{ function<void ()> fn;
string str( "hello word" );
auto lam = [str = str]() { cout << str << endl; };
fn = ref( lam );
fn();
}

Re: MSVC-bug

<uql3tc$3atoh$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3151&group=comp.lang.c%2B%2B#3151

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Thu, 15 Feb 2024 15:34:35 +0200
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <uql3tc$3atoh$1@dont-email.me>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 15 Feb 2024 13:34:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b9d99059a65ad01a1c6e65ef9db1ce5c";
logging-data="3503889"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Q4/MHk577BgDtmI+OBWp1W8AVkRemvxc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:oJ+UFJOy7iC+ejEowbT/vjSkNpI=
Content-Language: en-US
In-Reply-To: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
 by: Paavo Helde - Thu, 15 Feb 2024 13:34 UTC

13.02.2024 13:07 Bonita Montero kirjutas:
> If you initialize a function<>-object with a reference_wrapper it
> is  guaranteed that the function<>-object references an external
> function-object without any memory allocation. libstdc++ and libc++
> don't allocate any memory with such function<>-objects according
> to the standard, but MSVC does allocate external memory.

Cannot confirm that. MSVC++ 2022 x64 Release mode does not print "alloc"
at all for this program. In Debug mode there are a couple of allocs, but
these seem to be related to some std::string internals, not the
reference wrapper.

>
> #include <iostream>
> #include <functional>
>
> using namespace std;
>
> void *operator new( size_t n )
> {
>     cout << "alloc" << endl;
>     void *p = malloc( n );
>     if( !p )
>         throw bad_alloc();
>     return p;
> }
>
> void operator delete( void *p )
> {
>     free( p );
> }
>
> int main()
> {
>     function<void ()> fn;
>     string str( "hello word" );
>     auto lam = [str = str]() { cout << str << endl; };
>     fn = ref( lam );
>     fn();
> }

Re: MSVC-bug

<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3152&group=comp.lang.c%2B%2B#3152

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Thu, 15 Feb 2024 12:20:02 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 15 Feb 2024 15:28:08 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="437965f03bc30d128d08afd18b6f2265";
logging-data="3542622"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oDBiQka97to3ruzk3IYIpXd6KqFk9SH8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3F2ViW+MpSeGql1XbCVXzz7ySr4=
Content-Language: de-DE
In-Reply-To: <uql3tc$3atoh$1@dont-email.me>
 by: Bonita Montero - Thu, 15 Feb 2024 11:20 UTC

Am 15.02.2024 um 14:34 schrieb Paavo Helde:

> Cannot confirm that. MSVC++ 2022 x64 Release mode does not print "alloc"
> at all for this program. In Debug mode there are a couple of allocs, but
> these seem to be related to some std::string internals, not the
> reference wrapper.

Sorry, I relied on the Debug build.
With Release build there are no allocations.
But I think the Debug build should also be up to the standard.

Re: MSVC-bug

<uqm260$3gd7u$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3153&group=comp.lang.c%2B%2B#3153

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Fri, 16 Feb 2024 00:11:12 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <uqm260$3gd7u$1@dont-email.me>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 15 Feb 2024 22:11:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b9d99059a65ad01a1c6e65ef9db1ce5c";
logging-data="3683582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ly0isn2gzB+sEcvDa10e3PZIocoee58Y="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1hmcLQbYQlvK+bfz9r3UrF1aobc=
In-Reply-To: <uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
Content-Language: en-US
 by: Paavo Helde - Thu, 15 Feb 2024 22:11 UTC

15.02.2024 13:20 Bonita Montero kirjutas:
> Am 15.02.2024 um 14:34 schrieb Paavo Helde:
>
>> Cannot confirm that. MSVC++ 2022 x64 Release mode does not print
>> "alloc" at all for this program. In Debug mode there are a couple of
>> allocs, but these seem to be related to some std::string internals,
>> not the reference wrapper.
>
> Sorry, I relied on the Debug build.
> With Release build there are no allocations.
> But I think the Debug build should also be up to the standard.
>

Constructing and copying std::strings is allowed to allocate dynamic
memory. Make your string a bit longer and you will see allocations also
in Release builds.

Re: MSVC-bug

<uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3154&group=comp.lang.c%2B%2B#3154

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.bbs.nz!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Fri, 16 Feb 2024 09:17:11 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
<uqm260$3gd7u$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 16 Feb 2024 08:17:11 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="0bbe64c2c8ccd886cc1a78e450030725";
logging-data="3974415"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hMWXMIAuLGYh2XxRpho4IznttS1q54tE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ghOvU3FYRq+MJoJP2gQqFAxfahE=
Content-Language: de-DE
In-Reply-To: <uqm260$3gd7u$1@dont-email.me>
 by: Bonita Montero - Fri, 16 Feb 2024 08:17 UTC

Am 15.02.2024 um 23:11 schrieb Paavo Helde:

> Constructing and copying std::strings is allowed to allocate dynamic
> memory. Make your string a bit longer and you will see allocations
> also in Release builds.

The small string optimization is nothing which is guaranteed.
Initializing a function object with a reference_wrapper is
guaranteed to be without memory allocation.

Re: MSVC-bug

<urrmgq$12lh3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3167&group=comp.lang.c%2B%2B#3167

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Thu, 29 Feb 2024 20:45:12 -0800
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <urrmgq$12lh3$1@dont-email.me>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
<uqm260$3gd7u$1@dont-email.me>
<uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Mar 2024 04:45:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d080a32c13fb972ac462368775d2b18c";
logging-data="1136163"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18toRdddaiEe2MB2JZsPL4l"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JUt0eAUDMqCLlXn53MJYyjVAKmY=
Content-Language: en-US
In-Reply-To: <uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org>
 by: Andrey Tarasevich - Fri, 1 Mar 2024 04:45 UTC

On 02/16/24 12:17 AM, Bonita Montero wrote:
>
> The small string optimization is nothing which is guaranteed.
> Initializing a function object with a reference_wrapper is
> guaranteed to be without memory allocation.
>

Why do you keep spewing this nonsense?

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.

--
Best regards,
Andrey

Re: MSVC-bug

<ursmlf$18r2d$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3170&group=comp.lang.c%2B%2B#3170

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Fri, 1 Mar 2024 14:53:58 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <ursmlf$18r2d$1@raubtier-asyl.eternal-september.org>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
<uqm260$3gd7u$1@dont-email.me>
<uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org>
<urrmgq$12lh3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Mar 2024 13:53:51 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="562ca5826301ca46c61678f52578b195";
logging-data="1338445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nZAX5fL4uIfgj3L38kyoLm4vY04FKBuA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zpIrX8DXgiN66wpr2alSz6tFOMI=
Content-Language: de-DE
In-Reply-To: <urrmgq$12lh3$1@dont-email.me>
 by: Bonita Montero - Fri, 1 Mar 2024 13:53 UTC

Am 01.03.2024 um 05:45 schrieb Andrey Tarasevich:
> On 02/16/24 12:17 AM, Bonita Montero wrote:
>>
>> The small string optimization is nothing which is guaranteed.
>> Initializing a function object with a reference_wrapper is
>> guaranteed to be without memory allocation.
>>
>
> Why do you keep spewing this nonsense?
>
> 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.

#include <iostream>
#include <functional>

using namespace std;

void *operator new( size_t n )
{ cout << "alloc" << endl;
void *p = malloc( n );
if( !p )
throw bad_alloc();
return p;
}

void operator delete( void *p )
{ free( p );
}

int main()
{ function<void ()> fn;
string str( "hello word" );
auto lam = [&str]() { cout << str << endl; };
fn = ref( lam );
fn();
}

Re: MSVC-bug

<uru3ps$1i8fc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3173&group=comp.lang.c%2B%2B#3173

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Fri, 1 Mar 2024 18:44:12 -0800
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <uru3ps$1i8fc$1@dont-email.me>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
<uqm260$3gd7u$1@dont-email.me>
<uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org>
<urrmgq$12lh3$1@dont-email.me>
<ursmlf$18r2d$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 2 Mar 2024 02:44:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0c95f5849fd7969cdf0526beba2d8ebc";
logging-data="1647084"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nNjGyyjxcRyM4D7bKwrry"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:myruso7H6gQ+Bj8iGAprenL83pU=
Content-Language: en-US
In-Reply-To: <ursmlf$18r2d$1@raubtier-asyl.eternal-september.org>
 by: Andrey Tarasevich - Sat, 2 Mar 2024 02:44 UTC

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`, and has nothing to do with `std::function<>`.

Do this

...
int main()
{
function<void ()> fn;
string str( "hello word" );
auto lam = [&str]() { cout << str << endl; };

cout << "---" << endl;

fn = ref( lam );

cout << "---" << endl;

fn();
}

Your "alloc" is printed before the first "---".

--
Best regards,
Andrey

Re: MSVC-bug

<uruhca$1ocbb$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3176&group=comp.lang.c%2B%2B#3176

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Sat, 2 Mar 2024 07:36:00 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <uruhca$1ocbb$1@raubtier-asyl.eternal-september.org>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
<uqm260$3gd7u$1@dont-email.me>
<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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 2 Mar 2024 06:35:54 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="f9047fbcab9d30f29491e78f7dd1b6ad";
logging-data="1847659"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yuuUkO9eoP8l34yR4QVn/2DLvJdMrUuo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BCYIoY2MyOqCO6fq7iL7TexXp8U=
In-Reply-To: <uru3ps$1i8fc$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 2 Mar 2024 06:36 UTC

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.

>
> Do this
>
>   ...
>   int main()
>   {
>     function<void ()> fn;
>     string str( "hello word" );
>     auto lam = [&str]() { cout << str << endl; };
>
>     cout << "---" << endl;
>
>     fn = ref( lam );
>
>     cout << "---" << endl;
>
>     fn();
>   }
>
> Your "alloc" is printed before the first "---".
>

Re: MSVC-bug

<us02nk$22aa3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3177&group=comp.lang.c%2B%2B#3177

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++
Subject: Re: MSVC-bug
Date: Sat, 2 Mar 2024 12:38:12 -0800
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <us02nk$22aa3$1@dont-email.me>
References: <uqfih1$22741$1@raubtier-asyl.eternal-september.org>
<uql3tc$3atoh$1@dont-email.me>
<uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org>
<uqm260$3gd7u$1@dont-email.me>
<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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 2 Mar 2024 20:38:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fd7ad9070ecf9d4d1cc9dd7f0ec0dbe1";
logging-data="2173251"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6SKnqnKWUL3+KjZMplYwF"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kf7NfhXpodK8yllQadhbipvU7dg=
Content-Language: en-US
In-Reply-To: <uruhca$1ocbb$1@raubtier-asyl.eternal-september.org>
 by: Andrey Tarasevich - Sat, 2 Mar 2024 20:38 UTC

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


devel / comp.lang.c++ / MSVC-bug

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor