public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/111284] [11/12/13/14 Regression] Some passing-by-value parameters are mishandled since GCC 9, affecting libstdc++'s constexpr std::string
Date: Mon, 11 Mar 2024 15:12:04 +0000	[thread overview]
Message-ID: <bug-111284-4-mhNNgjkFwG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111284-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111284

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> Created attachment 57648 [details]
> gcc14-pr111284.patch
> 
> So, I've tried to fix this by constexpr evaluating the arguments passed to
> PARM_DECLs with TREE_ADDRESSABLE types in the caller as lvalues rather than
> rvaluea and later, if we try to evaluate the PARM_DECL in the callee as lval,
> lookup the value and use that, if it is rval constexpr evaluate again as
> rvalue.
> There is a complication for qualified type, say if the argument is const in
> the callee and caller is passing reference to non-const, adjust_temp_type
> can't handle that when it isn't a rvalue.
Interesting, hopefully this fixes the std::string testcases in PR111258 and
related PRs?

And perhaps the following augmented testcase from this PR with a constexpr dtor
that checks valid():

void non_constant();

struct self_locator {
    self_locator() = default;
    constexpr self_locator(const self_locator&) noexcept : this_{this} {}
    constexpr self_locator& operator=(const self_locator&) noexcept { return
*this; }

    constexpr bool valid() const noexcept { return this_ == this; }
    constexpr ~self_locator() { if (!valid()) non_constant(); }

    self_locator *this_ = this;
};

constexpr bool demonstrator(self_locator x) noexcept
{
    return x.valid();
}

static_assert(demonstrator(self_locator{}), "");
static_assert([](self_locator x){ return x.valid(); }(self_locator{}), "");

  parent reply	other threads:[~2024-03-11 15:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 11:16 [Bug c++/111284] New: Some passing-by-value parameters are miscompiled since GCC 9 de34 at live dot cn
2023-09-05 14:37 ` [Bug c++/111284] [11/12/13/14 Regression] Some passing-by-value parameters are mishandled " mpolacek at gcc dot gnu.org
2023-09-05 14:37 ` mpolacek at gcc dot gnu.org
2023-09-05 18:00 ` jakub at gcc dot gnu.org
2023-09-05 18:04 ` jakub at gcc dot gnu.org
2023-09-05 19:21 ` jakub at gcc dot gnu.org
2023-09-05 19:27 ` jakub at gcc dot gnu.org
2023-09-11 11:32 ` jakub at gcc dot gnu.org
2023-09-11 12:12 ` jakub at gcc dot gnu.org
2024-03-07 18:58 ` [Bug c++/111284] [11/12/13/14 Regression] Some passing-by-value parameters are mishandled since GCC 9, affecting libstdc++'s constexpr std::string jakub at gcc dot gnu.org
2024-03-11 15:12 ` ppalka at gcc dot gnu.org [this message]
2024-04-25 18:46 ` cvs-commit at gcc dot gnu.org
2024-04-25 18:48 ` [Bug c++/111284] [11/12/13 " jakub at gcc dot gnu.org
2024-05-09  4:26 ` cvs-commit at gcc dot gnu.org
2024-05-09  8:17 ` [Bug c++/111284] [11/12 " jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111284-4-mhNNgjkFwG@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).