Skip to content

CWG3118 [basic.link] Mangling reflections of annotations is infeasible #796

@katzdm

Description

@katzdm

Full name of submitter: Dan Katz

Reference (section label): [basic.link]/16.4

Issue description
An annotation ([dcl.attr]) on a declaration is unique among all annotations on all declarations in all TUs, which makes mangling them infeasible. This was known at the time of P3394, but work on the ongoing GCC implementation surfaced that we did an inadequate job specifying this.

Consider the following:

[[=1]] void f();
constexpr auto R = annotations_of(^^f)[0];

template <std::meta::info> struct TCls {};

If the above were in a header file included by two TUs, the result would be two distinct declarations [[=1]] void f(); with two distinct annotations; mangling TCls<R> would therefore (hypothetically) not be a concern. Use of modules, however, could lead to R being exported across TU boundaries, leading to situations where TCls<R> needs to be mangled.

Suggested resolution
Reflections of annotations should be TU-local values.

Add a bullet to [basic.link]/16.4 as follows:

it is a reflection value ([basic.fundamental]) that represents

  • an entity, value, or object that is TU-local,
  • an annotation ([dcl.attr),
  • a direct base class relationship (D, B) ([class.derived.general]) for which either D or B is TU-local, or
  • a data member description (T, N, A, W, NUA) ([class.mem.general]) for which T is TU-local.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions