CGF and initializers


I’m investigating a bug where -Wmissing-noreturn warns on any constructor with member or base initializers, for example:

int f();

struct A {
int a;
A() : a(f()) { }

The CFG for A::A() looks like:

[ B2 (ENTRY) ]
Predecessors (0):
Successors (1): B1

[ B1 ]
1: f()
2: a([B1.1]) (Member initializer)
Predecessors (1): B2
Successors (1): B0

[ B0 (EXIT) ]
Predecessors (1): B1
Successors (0):

not sure about this, but wouldn’t it make more sense for the member initializer to come before the call to f() ?

  • Anders

Hi Anders,

The value of f() is used for initializing the member, so there is a control-dependency between the call to f() and the member initializer, not the other way around. The member is initialized after the call.