C++ Logo

std-discussion

Advanced search

Equivalence of unnamed types across translation units

From: Myria <myriachan_at_[hidden]>
Date: Mon, 29 Jul 2019 20:45:49 -0700
Let's say that you had a header file #included by multiple translation
units that contains:

    const struct { } a;
    struct b : decltype(a) { };

Is this a violation of the One Definition Rule? The unnamed type of
"a" has either no or internal linkage (I'm not sure which), so each
translation unit's struct b derives from a different base class,
breaking the One Definition Rule...?

Similarly, this could be asked about anonymous namespaces and lambdas:

    namespace { struct a { }; }
    struct b : a { };

    static auto a = []{};
    struct b : decltype(a) { };

Melissa

Received on 2019-07-29 22:48:00