public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67519] New: New warning: calls to member functions before all base classes constructed
@ 2015-09-09 13:04 redi at gcc dot gnu.org
  2015-09-09 13:25 ` [Bug c++/67519] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-09 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67519
           Summary: New warning: calls to member functions before all base
                    classes constructed
           Product: gcc
           Version: 4.9.4
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

It's undefined to (directly or indirectly) call a member function in a
ctor-initializer before all the mem-initializers for base classes have
completed ([class.base.init] p16).

It should be possible to warn about this, at least for simple cases.

The example in [class.base.init] p16 should give two warnings:

class A {
public:
  A(int);
};

class B : public A {
  int j;
public:
  int f();
  B() : A(f()), // undefined: calls member function
                // but base A not yet initialized
  j(f()) { }    // well-defined: bases are all initialized
};

class C {
public:
  C(int);
};

class D : public B, C {
  int i;
public:
  D() : C(f()), // undefined: calls member function
                // but base C not yet initialized
  i(f()) { }    // well-defined: bases are all initialized
};


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

end of thread, other threads:[~2015-09-12 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-09 13:04 [Bug c++/67519] New: New warning: calls to member functions before all base classes constructed redi at gcc dot gnu.org
2015-09-09 13:25 ` [Bug c++/67519] " pinskia at gcc dot gnu.org
2015-09-12 14:44 ` trippels at gcc dot gnu.org
2015-09-12 16:16 ` [Bug c++/67519] warn for " manu 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).