Structure constructor with procedure pointer component

It took me a while to work through what the standard says about this.

First, you have an array constructor as the initialization value for a named (PARAMETER) constant. The standard requires that this be a constant expression.

Next, we go to the rules for constant expressions (10.1.12). Here, an array constructor is fine as long as each element is a constant expression.

We’re still in 10.1.12, (3)(b) in this case, for structure constructors, where each pointer component “is an initialization target or a reference to the intrinsic function NULL,”.

So, what is an initialization target? For that we go to 8.2 where we see this:

R805 initialization is = constant-expr
or => null-init
or => initial-data-target

Oh, look. Initialization to a procedure target is not allowed! Therefore, you can’t have a procedure in a constant expression.

I seem to recall that there was some discussion earlier of allowing initialization of procedure pointers, but it didn’t make it in.

3 Likes