C++ Logo

std-proposals

Advanced search

Re: [std-proposals] volatile is not well supported

From: Charles Milette <charlesmilette_at_[hidden]>
Date: Thu, 1 Sep 2022 19:37:10 -0400
I believe you want an atomic<shared_ptr<int>>, not volatile.

On Thu, Sep 1, 2022 at 7:24 PM Phil Bouchard via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Greetings,
>
> In this age of multicores and multithreaded applications, today at work I
> did try to mark an entire struct as volatile and I couldn't compile a
> simple application. Here is a simple replicate:
>
>
> #include <memory>
>
> using namespace std;
>
> struct Data
> {
> shared_ptr<int> p;
> };
>
> int main()
> {
> static Data volatile cData;
>
> cData.p = make_shared<int>(9);
>
> return 0;
> }
>
> volatile.cpp:14:13: error: no viable overloaded '='
> cData.p = make_shared<int>(9);
>
> I think it would be convenient to fix this issue in this age of parallel
> programming.
>
>
> Regards,
>
> --
> [image: Logo] <https://www.fornux.com/>
> *Phil Bouchard* [image: facebook icon]
> <https://www.linkedin.com/in/phil-bouchard-5723a910/>
> CTO
> T: (819) 328-4743
> E: phil_at_[hidden] | www.fornux.com
> 1188 rue Saint-Louis | Gatineau (Qc), J8T 2L8 Canada
> [image: Banner] <https://goglobalawards.org/> Le message ci-dessus, ainsi
> que les documents l'accompagnant, sont destinés uniquement aux personnes
> identifiées et peuvent contenir des informations privilégiées,
> confidentielles ou ne pouvant être divulguées. Si vous avez reçu ce message
> par erreur, veuillez le détruire.
> This communication (and/or the attachments) is intended for named
> recipients only and may contain privileged or confidential information
> which is not to be disclosed. If you received this communication by mistake
> please destroy all copies.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-09-01 23:37:22