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

            Bug ID: 114675
           Summary: warning for "reference to not fully constructed
                    object"
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Simon.Richter at hogyros dot de
  Target Milestone: ---

We have an object that contains several sub-objects that should reference each
other through interface pointers. I'd like to make sure that interface pointers
given to objects constructed later already point to initialized objects.

So, for

struct everything {
    everything() : a(), b(c), c(a) { }

    A a;
    B b;
    C c;
};

I'm passing a reference to the not-yet-constructed C object to B's constructor,
so this is unsafe despite being legal C++. I wonder if it would be possible to
generate a warning here.

Reply via email to