Skip to content

mangling of array new #199

@jicama

Description

@jicama

I notice that the mangling of new-expressions is specified as

           ::= [gs] nw <expression>* _ <type> E                     # new (expr-list) type
           ::= [gs] nw <expression>* _ <type> <initializer>         # new (expr-list) type (init)
           ::= [gs] na <expression>* _ <type> E                     # new[] (expr-list) type
           ::= [gs] na <expression>* _ <type> <initializer>         # new[] (expr-list) type (init)

The new[] mangling doesn't clarify how the length of the array allocation is encoded. GCC encodes it into the type by building an array type; Clang seems to not encode it at all. So, for

template <unsigned> struct A { };
template<typename T>
auto foo() -> A<sizeof(new T[42])>
{ return {}; }
int main() { foo<int>(); }

GCC mangles foo as _Z3fooIiE1AIXszna_A42_T_EEEv,
Clang as _Z3fooIiE1AIXszna_T_EEEv

Any objection to clarifying that the GCC mangling is correct?

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