[odb-users] Virtual std::vector< odb::lazy_shared_ptr<X> > crashes
odb compiler
dieter.govaerts at bricsys.com
dieter.govaerts at bricsys.com
Thu Mar 24 16:18:48 EDT 2016
Hi,
I'm experiencing an odb internal compiler crash when declaring a virtual std::vector< odb::lazy_shared_ptr<X> > member. Exchanging the odb::lazy_shared_ptr with a std::shared_ptr (undefine LAZY_PTR_VECTOR) or making the vector non-virtual (define NON_VIRTUAL) avoids the crash. The following code illustrates the this (I've reduced the code to the bare minimum):
#ifndef TEST_2_H
#define TEST_2_H
#include <memory>
#include <odb/core.hxx>
#include <odb/lazy-ptr.hxx>
#define LAZY_PTR_VECTOR
#ifdef LAZY_PTR_VECTOR
//#define NON_VIRTUAL
#endif
#ifndef LAZY_PTR_VECTOR
//#define NO_PRE_DECL_CRASH
#endif
#ifndef NO_PRE_DECL_CRASH
class Employee;
typedef std::shared_ptr<Employee> EmployeePtr;
#endif
class Employer;
typedef std::shared_ptr<const Employer> ConstEmployerPtr;
#pragma db object session
struct Employee
{
#pragma db id auto
unsigned id_;
ConstEmployerPtr employer_;
};
#ifdef LAZY_PTR_VECTOR
typedef std::vector< odb::lazy_shared_ptr<Employee> > Employees;
#else
typedef std::vector< std::shared_ptr<Employee> > Employees;
#endif
#pragma db value(Employees) value_not_null
#pragma db object session
struct Employer
{
#pragma db id auto
unsigned id_;
#pragma db inverse(employer_)
#ifdef NON_VIRTUAL
Employees employees_;
#else
#pragma db member(employees) virtual(Employees) access(this.impl().m_employees)
#endif
};
#endif //TEST_2_H
Another crash occurs when undefining LAZY_PTR_VECTOR and defining NO_PRE_DECL_CRASH. I'm not sure it is related to the other. This one is less of a problem to me, I just came across it when reducing the code.
Dieter
More information about the odb-users
mailing list