C++ Logo

STD-DISCUSSION

Advanced search

Subject: Equivalence of unnamed types across translation units
From: Myria (myriachan_at_[hidden])
Date: 2019-07-29 22:45:49


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


STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups