In C++20 the wording was changed so that only names have linkage. I assume the types are different because there's no rule saying they're the same, so I would agree that multiple definitions of `b` violate the ODR.

In the second and third cases, I think this is less controversial.


On Mon, Jul 29, 2019 at 10:46 PM Myria via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
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 mailing list
Std-Discussion@lists.isocpp.org
http://lists.isocpp.org/mailman/listinfo.cgi/std-discussion


--
Brian Bi