Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"BTW, does Jesus know you flame?" -- Diane Holt, dianeh@binky.UUCP, to Ed Carp


devel / comp.lang.c++ / Trying to get std::launder to actually do something

SubjectAuthor
* Trying to get std::launder to actually do somethingFrederick Virchanza Gotham
+- Re: Trying to get std::launder to actually do somethingAlf P. Steinbach
`- Re: Trying to get std::launder to actually do somethingPavel

1
Trying to get std::launder to actually do something

<7e2bf171-edd1-4a17-92bb-cb74a561465fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:14b1:b0:640:14de:a493 with SMTP id bo17-20020a05621414b100b0064014dea493mr36285qvb.3.1692376968246;
Fri, 18 Aug 2023 09:42:48 -0700 (PDT)
X-Received: by 2002:a17:90b:489:b0:26d:1f4c:a608 with SMTP id
bh9-20020a17090b048900b0026d1f4ca608mr692628pjb.5.1692376967597; Fri, 18 Aug
2023 09:42:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Fri, 18 Aug 2023 09:42:46 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=94.119.64.15; posting-account=w4UqJAoAAAAYC-PItfDbDoVGcg0yISyA
NNTP-Posting-Host: 94.119.64.15
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7e2bf171-edd1-4a17-92bb-cb74a561465fn@googlegroups.com>
Subject: Trying to get std::launder to actually do something
From: cauldwel...@gmail.com (Frederick Virchanza Gotham)
Injection-Date: Fri, 18 Aug 2023 16:42:48 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Frederick Virchanza - Fri, 18 Aug 2023 16:42 UTC

C++17 introduced std::launder, and C++23 introduced std::start_lifetime_as, so it seems the Standards guys are really taking the 'object model' seriously.

Amidst all this seriousness though, those two functions are no-op's for most compilers.

Enthusiasts tried to find a situation in which std::launder actually does something, and they only found one example of C++ code that behaves
differently when you use 'launder', and it involved a constructor using
'placement new' to invoke a constructor belonging to another class on the
current object, something like:

MyClass::MyClass(void)
{ ::new(this) SomeOtherClass();
}

The use of 'launder' on the pointer to this object prevented caching of the vtable, you can see what they did here:

https://miyuki.github.io/2016/10/21/std-launder.html

I achieved something similar by marking the object as 'volatile' in a puzzle I composed on Codewars:

https://www.codewars.com/kata/6359c81e00fba2852618a1cb/

I've been mulling over the idea though of using 'placement new' inside a class's constructor in order to change its vtable. Can anyone think of any weird, wild and wacky uses of this?

Re: Trying to get std::launder to actually do something

<ubobq9$blc2$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.st...@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: Trying to get std::launder to actually do something
Date: Fri, 18 Aug 2023 20:03:52 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ubobq9$blc2$2@dont-email.me>
References: <7e2bf171-edd1-4a17-92bb-cb74a561465fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Aug 2023 18:03:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e0a6886b19baacef06df7af52a0891b";
logging-data="382338"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dEC+63hHfllBv3euiXUU5"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:QodmtHsUjlRPGKlnDIktCXkKMO4=
Content-Language: en-US
In-Reply-To: <7e2bf171-edd1-4a17-92bb-cb74a561465fn@googlegroups.com>
 by: Alf P. Steinbach - Fri, 18 Aug 2023 18:03 UTC

On 2023-08-18 6:42 PM, Frederick Virchanza Gotham wrote:
> Enthusiasts tried to find a situation in which std::launder actually does something

Would be nice with a link to that.

- Alf

Re: Trying to get std::launder to actually do something

<8wUDM.560205$SuUf.132185@fx14.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
Subject: Re: Trying to get std::launder to actually do something
Newsgroups: comp.lang.c++
References: <7e2bf171-edd1-4a17-92bb-cb74a561465fn@googlegroups.com>
From: pauldont...@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <7e2bf171-edd1-4a17-92bb-cb74a561465fn@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 35
Message-ID: <8wUDM.560205$SuUf.132185@fx14.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 19 Aug 2023 01:01:56 UTC
Date: Fri, 18 Aug 2023 21:01:44 -0400
X-Received-Bytes: 2279
 by: Pavel - Sat, 19 Aug 2023 01:01 UTC

Frederick Virchanza Gotham wrote:
>
> C++17 introduced std::launder, and C++23 introduced std::start_lifetime_as, so it seems the Standards guys are really taking the 'object model' seriously.
>
> Amidst all this seriousness though, those two functions are no-op's for most compilers.
>
> Enthusiasts tried to find a situation in which std::launder actually does something, and they only found one example of C++ code that behaves
> differently when you use 'launder', and it involved a constructor using
> 'placement new' to invoke a constructor belonging to another class on the
> current object, something like:
>
> MyClass::MyClass(void)
> {
> ::new(this) SomeOtherClass();
> }
>
> The use of 'launder' on the pointer to this object prevented caching of the vtable, you can see what they did here:
>
> https://miyuki.github.io/2016/10/21/std-launder.html
>
> I achieved something similar by marking the object as 'volatile' in a puzzle I composed on Codewars:
>
> https://www.codewars.com/kata/6359c81e00fba2852618a1cb/
>
> I've been mulling over the idea though of using 'placement new' inside a class's constructor in order to change its vtable. Can anyone think of any weird, wild and wacky uses of this?
>
I can only think of a reason why finding a good use for this is
difficult -- because changing "a vtable" or, in impl-independent
paralnce, "a dynamic type" is exactly what creating an object of a
derived class does, likely better.

-Pavel


devel / comp.lang.c++ / Trying to get std::launder to actually do something

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor