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

            Bug ID: 123849
           Summary: ICE (segfault) involving operator new and
                    std::float16_t
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: josopait at goopax dot com
  Target Milestone: ---

Compiling the following program fails with internal compiler error:
Segmentation fault.
I tried gcc 13, 14, and 15.
Compile with -std=c++23


#include <stdfloat>

template<typename Derived> class MatrixBase
{
public:
  MatrixBase();
};

template<typename Derived>
class PlainObjectBase : public MatrixBase<Derived>
{
public:
  void *operator new(std::size_t size);
  void operator delete(void * ptr);
};

template<typename _Scalar>
class Matrix
  : public PlainObjectBase<Matrix<_Scalar> >
{
};

template<typename T>
struct resource
{
  T& makeref() const
  {
    T* ret = new T;
    return *ret;
  }
};


using T = Matrix<std::float16_t>;

void func(resource<T>& A)
{
  T& a = A.makeref();
}

Reply via email to