public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114675] New: warning for "reference to not fully constructed object"
@ 2024-04-10  9:15 Simon.Richter at hogyros dot de
  2024-04-10 10:42 ` [Bug c++/114675] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon.Richter at hogyros dot de @ 2024-04-10  9:15 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/114675] warning for "reference to not fully constructed object"
  2024-04-10  9:15 [Bug c++/114675] New: warning for "reference to not fully constructed object" Simon.Richter at hogyros dot de
@ 2024-04-10 10:42 ` redi at gcc dot gnu.org
  2024-04-10 11:14 ` pinskia at gcc dot gnu.org
  2024-04-10 12:12 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-10 10:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A complete testcase that actually compiles:

struct A { };
struct C { C(const A&); };
struct B { B(const C&); };

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

    A a;
    B b;
    C c;
};

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/114675] warning for "reference to not fully constructed object"
  2024-04-10  9:15 [Bug c++/114675] New: warning for "reference to not fully constructed object" Simon.Richter at hogyros dot de
  2024-04-10 10:42 ` [Bug c++/114675] " redi at gcc dot gnu.org
@ 2024-04-10 11:14 ` pinskia at gcc dot gnu.org
  2024-04-10 12:12 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-10 11:14 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-10
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> A complete testcase that actually compiles:
> 
> struct A { };
> struct C { C(const A&); };
> struct B { B(const C&); };
> 
> struct everything {
>     everything() : a(), b(c), c(a) { }
> 
>     A a;
>     B b;
>     C c;
> };

Confirmed. I thought I had saw another bug which was asking for the same thing
but I can't seem to find it right now.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/114675] warning for "reference to not fully constructed object"
  2024-04-10  9:15 [Bug c++/114675] New: warning for "reference to not fully constructed object" Simon.Richter at hogyros dot de
  2024-04-10 10:42 ` [Bug c++/114675] " redi at gcc dot gnu.org
  2024-04-10 11:14 ` pinskia at gcc dot gnu.org
@ 2024-04-10 12:12 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-10 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yeah I looked for a dup too, as I'm sure this has been reported before.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-10 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10  9:15 [Bug c++/114675] New: warning for "reference to not fully constructed object" Simon.Richter at hogyros dot de
2024-04-10 10:42 ` [Bug c++/114675] " redi at gcc dot gnu.org
2024-04-10 11:14 ` pinskia at gcc dot gnu.org
2024-04-10 12:12 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).