From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id B228B38937FD for ; Mon, 12 Dec 2022 11:56:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B228B38937FD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x629.google.com with SMTP id bj12so27257087ejb.13 for ; Mon, 12 Dec 2022 03:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hSCJyzVQCZLBc8xbZFMsTWmuD1775pJtQj8htdstmfo=; b=h56jvqEGlS0F11yUYjUK5J7aQ9Qamw/97PbC24ODNgqXZSV9ujgslduICRG548T473 yofETqE5SK7kdaZDeyAVqZ2GAP/rmizN8Ycs4jDQB5fXL+mtd0K5fZOUhuHx1DBggYf2 45VUHDeW564RpWDCSPHVF7WjVOUp3TIry9d6MJRNLE5ITozKupFWcYCN6F/EYI4gyCih 5mZ/TNcoSWosF1Y1VVmnkIBIZ1D5a1ki/Q+8/K3h03nRh7nwXkecmFRTUJQ5lOm3llWY 9UKbq/hq6uuwovFpI5XnIYSpvRBkfWS5NfFOaKPIh55B5x5Aa6fzctliH/6YxK5dfIUC j7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hSCJyzVQCZLBc8xbZFMsTWmuD1775pJtQj8htdstmfo=; b=SIfM5dshcJL/5x/zRWIla6md8TXYUEjocyA2Bsm+aW7Ru87yIItP/4gL3xSYFt6C1v eEaXQSsFkjcT/T487bPni7DI0aCbK6KIJV0ZR2QHakxOVcu5LYOYkw7o8C1FiPRKOItd wL3J7MW6PdfnIvrDdy/oyS8MQhmJ1NNyk7IH393D2ln6e+rZx7n4cRJ2vTGEephRtZrh Q07Or4KmjC9JT3mwCIyXHpR0O0NsOjNpfF2x+9ALlLGIyBsrVZ0j/liSmjqFhW92qT3i ZMf6FK4CQ7e9Uo7Jml2NNZpTL2PcmdVJg13IDHUswYnIqIBIcy80n6LuE46NST3YEQO3 CtYg== X-Gm-Message-State: ANoB5pn1tj1rsga2EQlTISZxgXePFD9u13vwklIy+N4UbUa0WSvdElFs T2kZDlK3gZ1v43gaAwZwTyJha7/4yoRhigb6dP4= X-Google-Smtp-Source: AA0mqf6Kcpy17UtxvBOY7OyvzBHEgxbODfrJqcTXxHD5agaltwGcxTBh6sVaU77juIhs5J9PVmVlj16rjxNjpK1pH1Q= X-Received: by 2002:a17:907:9096:b0:7c0:e306:8930 with SMTP id ge22-20020a170907909600b007c0e3068930mr17911414ejb.386.1670846210445; Mon, 12 Dec 2022 03:56:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Mon, 12 Dec 2022 11:56:39 +0000 Message-ID: Subject: Re: Bug with GCC's handling of lifetimes of implicit-lifetime types To: Gavin Ray Cc: Richard Biener , Andrew Pinski , "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, 11 Dec 2022 at 13:44, Gavin Ray wrote: > > Whoops, the last line should be pages_span(storage, ...) That won't even compile, so there's your main difference. That seems even more off-topic on this list than "somebody told me gcc is broken, because of [unrelated code example with UB]". A creates 'pages' objects in the storage, B doesn't compile, but even if it did, it's just saying "look at this storage as though it contained this many objects of type 'pages'" which doesn't create any objects, and would be a lie. > > On Sun, Dec 11, 2022 at 8:38 AM Gavin Ray wrote: >> >> @Richard >> >> That's some intense code, I appreciate the code-samples and explanation, thank you =) >> >> @Jonathan >> >> Maybe there was some misunderstanding? >> I didn't make the connection either but I also don't know that much about C++ >> >> It seems like that expression is valid then? Good to know =) >> >> As a random aside if I may -- what is the difference between placement-new of pointers in >> std::byte storage, and making a std::span over the storage area? >> >> std::byte storage[PAGE_SIZE * NUM_PAGES]; >> >> // A) >> page* pages = new (storage) page[NUM_PAGES]; >> // B) >> std::span pages_span(pages, NUM_PAGES);