Three different function definitions; no linker error; how can it be?

I have something that seems very impossible to me. I have three files, each of which seems to contain the same function declaration, albeit with a different definition.

inst_dp_vec2.cc:

void loadSOAFVec(InstVector &ivector,
                 const FVec &ret,
                 const Address *a,
                 int soanum,
                 int soalen,
                 string mask) {
    if (soalen == 2) {
        ivector.push_back(new LoadFVec(ret, a, string("")));
    } else {
        printf("SOALEN = %d not supported at %s:%d\n", soalen, __FILE__,
               __LINE__);
        exit(1);
    }
}

inst_dp_vec4.cc

void loadSOAFVec(InstVector &ivector,
                 const FVec &ret,
                 const Address *a,
                 int soanum,
                 int soalen,
                 string mask) {
    if (soalen == 4) {
        ivector.push_back(new LoadFVec(ret, a, string("")));
    } else if (soalen == 2) {
        ivector.push_back(new LoadHalfFVec(ret, a, soanum));
    } else {
        UNSUPPORTED_SOALEN(soalen);
    }
}

inst_dp_vec8.cc

void loadSOAFVec(InstVector &ivector,
                 const FVec &ret,
                 const Address *a,
                 int soanum,
                 int soalen,
                 string mask) {
    int mskbits = (((1 << soalen) - 1) << (soanum * soalen));
    stringstream mk;
    mk << "0x" << hex << mskbits;
    string localmask = mk.str();
    ivector.push_back(new LoadUnpackFVec(ret, a, localmask));
}

The linker command executed from the Makefile (generated by GNU Autotools) seems to include all three compiled files:

g++ -O3 -g -DNO_HW_MASKING -DUSE_LDUNPK -DUSE_PKST -DUSE_PACKED_GAUGES
-DUSE_PACKED_CLOVER -DNO_GPREF_L1 -DNO_GPREF_L2 -DENABLE_STREAMING_STORES
-DSERIAL_SPIN -DSOALEN=8 -DVECLEN=4 -DPRECISION=2 codegen.o data_types.o
dslash.o dslash_common.o inst_dp_vec8.o inst_sp_vec16.o inst_dp_vec4.o
inst_sp_vec8.o inst_sp_vec4.o inst_dp_vec2.o inst_scalar.o -o codegen

. , inst_dp_vec8.o , inst_dp_vec4.cc, . , UNSUPPORTED_SOALEN throws , GDB , soalen = 8 . , , soalen = 8 veclen ≥ 8, inst_dp_vec8.cc .

: , - , UNSUPPORTED_SOALEN?

+6
1

, .

[basic.def.odr]:

, , , .

- , (6.4.1); .

, , , , .

+8

Source: https://habr.com/ru/post/1014810/


All Articles