public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111284] New: Some passing-by-value parameters are miscompiled since GCC 9
@ 2023-09-04 11:16 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
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: de34 at live dot cn @ 2023-09-04 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111284
           Summary: Some passing-by-value parameters are miscompiled since
                    GCC 9
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

GCC incorrectly rejects the following program since GCC 9
(https://godbolt.org/z/cGK1a1dqK):
```
class self_locator {
public:
    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; }

private:
    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{}), "");
```

The `valid` member function should always return true. But if `self_locator` is
passed by value, GCC can sometimes render the parameter in an inconsistent
state (perhaps due to incorrect bitwise copy).

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-05-09  8:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).