What run-time costs are there to initializing a static with a variable value?-Collection of common programming errors

Initialisation from a compile-time constant (alternate 2) will most likely happen during program startup, with no cost each time the function is called.

Thread-safe initialisation of a local static variable will cause the compiler to generate something like this pseudocode:

static bool alternate1;

static bool __initialised = false;
static __lock_type __lock;
if (!__initialised) {
    acquire(__lock);
    if (!__initialised) {
        alternate1 = value;
        __initialised = true;
    }
    release(__lock);
}

So there is likely to be a test of a flag each time the function is called (perhaps involving a memory barrier or other synchronisation primitive), and a further cost of acquiring and releasing a lock the first time.

Note that in your code, foo() is called every time, whether or not the variable is initialised yet. It would only be called the first time, if you changed the initialisation to

static bool alternate1 = foo();

The details are implementation-dependent of course; this is based on my observations of the code produced by GCC.