[cfe-dev] CGF and initializers

Ted Kremenek kremenek at apple.com
Tue Jan 11 10:18:40 PST 2011


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.

On Jan 11, 2011, at 9:58 AM, Anders Carlsson wrote:

> Hello,
> 
> 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
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list