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

David Stone <david at doublewise dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david at doublewise dot net

--- Comment #1 from David Stone <david at doublewise dot net> ---
Here's another reproduction

```
struct s {
        int m_value = 0;

        constexpr int value() const {
                return m_value;
        }

        constexpr s()
        {
                value();
                m_value = 1;
        }
};

constexpr auto x = s();
static_assert(x.value() == 1);
```

Still a problem on trunk.

This example shows it's not just that side effects are ignored, but also that
the return value is cached. My guess is that there is some code path that
memoizes calls to constexpr functions, replacing them with their return value,
and that code is getting invoked when it shouldn't be.

Reply via email to