Bug 105882 - A possible constexpr bug
Summary: A possible constexpr bug
Status: RESOLVED DUPLICATE of bug 88174
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-08 07:10 UTC by zhonghao
Modified: 2022-06-08 07:16 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2022-06-08 07:10:17 UTC
The code sample is as follows:

#include <complex>

struct real128
{
    __float128 m_value;

    template <typename T>
    constexpr bool get(T &rop) const
    {
        using value_type = typename T::value_type;

        rop.real(static_cast<value_type>(m_value));
        rop.imag(static_cast<value_type>(0));

        return true;
    }
};

constexpr auto fappo(real128 x)
{
    std::complex<double> ret{1,2};
    x.get(ret);
    return ret;
}

constexpr auto flap = fappo(real128{4});

gcc rejects this code, but clang accepts it. mp++ is a library for multiprecision arithmetic. Its programmers disable several code lines, when gcc compiles this project. Please check:
https://github.com/bluescarni/mppp/commit/628651b9928e35dc09c0c2de3d2561abababb55f
Comment 1 Drea Pinski 2022-06-08 07:16:02 UTC
Dup of bug 88174.

*** This bug has been marked as a duplicate of bug 88174 ***