4.3.1 C++ name mangling differences in ARM Compiler v5.05

Various name mangling changes have been made in ARM Compiler v5.05.

Non-type non-dependent template arguments

When one template uses another template, the way that the non-type arguments to the used template that do not depend on the type parameters of the using template are mangled has changed.

The cases affected are:

sizeof

In ARM Compiler v5.04 expressions involving sizeof(x) had a mangling that included the sizeof. ARM Compiler v5.05 mangles the integer constant that the sizeof() expression evaluates to.

These changes in behavior might result in problems when all of the following conditions are true:

  • A translation unit is compiled with ARM Compiler v5.05.
  • A second translation unit is compiled with ARM Compiler v5.04 or earlier.
  • The translation units instantiate or refer to a template that includes sizeof(x).

__alignof

In ARM Compiler v5.04 in --gnu mode, expressions involving __alignof__(x) had a mangling that included the __alignof__. ARM Compiler v5.04 in --gnu mode mangles the integer constant that the __alignof__(x) expression evaluates to.

These changes in behavior might result in problems when all of the following conditions are true:

  • A translation unit is compiled with ARM Compiler v5.05 using the --gnu option.
  • A second translation unit is compiled with ARM Compiler v5.04 or earlier using the --gnu option.
  • The translation units instantiate or refer to a template that includes __alignof__(x) expressions.

Binary operations

In ARM Compiler v5.04, binary operations were included in the mangling. ARM Compiler v5.05 in C++11 mode has the same behavior. ARM Compiler v5.05 in non-C++11 mode evaluates the integer constant and then mangles the result.

This change might result in problems when all of the following conditions are true:

  • A translation unit is compiled with ARM Compiler v5.05 without the --cpp11 option.
  • A second translation unit is compiled with ARM Compiler v5.04 or earlier, or ARM Compiler v5.05 using the --cpp11 option.
  • The translation units instantiate or refer to a template that includes binary operations.

Example

The following example contains templates that include a sizeof and a binary operation:

file1.cpp

template <class T, T N> struct S {};
// f1 undefined if file1.cpp is compiled with 5.04 and file2.cpp is
// compiled with 5.05
template <class T> int f1(S<T, sizeof(char)>);
// f2 undefined if file1.cpp is compiled with 5.05 with --cpp11 or
// with 5.04 and file2.cpp is compiled with 5.05 without --cpp11.
template <class T> int f2(S<T, 1+1>);
int function()
{
    S<int,sizeof(char)> s1;
    S<int,1+1> s2;
    return f1(s1) + f2(s2);
}
			

file2.cpp

template <class T, T N> struct S {};
template <class T> int f1(S<T, sizeof(char)>)
{
    return 1;
}
template <class T> int f2(S<T, 1+1>)
{
    return 2;
}

template int f1<int>(S<int,sizeof(char)>);
template int f2<int>(S<int,1+1>);

extern int function();

int main()
{
    function();
}
			

Substitution of _Complex types

_Complex types are only available in C++ when using --gnu.

In ARM Compiler v5.04, _Complex types failed to have the substitution mechanism applied when generating name manglings. This has been fixed in ARM Compiler v5.05. However, this means that problems might occur when all of the following conditions are true:

  • A translation unit is compiled with ARM Compiler v5.05 using the --gnu option.
  • A second translation unit is compiled with ARM Compiler v5.04 or earlier using the --gnu option.
  • The translation units define or refer to a function that takes more than one _Complex argument.

Example

For example:

file1.cpp

// fn is undefined if file1.cpp is compiled with 5.04 and file2 is
// compiled with 5.05.
extern void fn(float _Complex a, float _Complex b);
int main()
{
    float _Complex cf;
    fn(cf, cf);
}
			

file2.cpp

void fn(float _Complex a, float _Complex b)
{

}
			

Const-volatile-qualified non-member function type as template argument

In ARM Compiler v5.04, armcc incorrectly mangled a const-volatile-qualified (cv-qualified) non-member function type used as a template argument as if it was not cv-qualified. This has been fixed in ARM Compiler v5.05.

This means that problems might occur when both of the following conditions are true:

  • A translation unit is compiled with ARM Compiler v5.05.
  • A second translation unit is compiled with ARM Compiler v5.04 or earlier.
  • One of these translation units defines or refers to a function that takes as an argument a template with an argument of cv-qualified non-member function type.

Example

file1.cpp

template <class T> struct A { };
typedef void cfn(int) const;
// f is undefined if file1.cpp is compiled with 5.04 and file2 is
// compiled with 5.05 or vice versa.
extern int f(A<cfn>);
int main()
{
    A<cfn> a;
    f(a);
}
			

file2.cpp

template <class T> struct A { };
typedef void cfn(int) const;
int f(A<cfn>)
{
    return 1;
}
			

lvalue of function type used as non-type template argument

In v5.04, an lvalue of function type used as a non-type template argument was incorrectly mangled as &(function_name()) instead of function_name(). This has been fixed in v5.05.

This means that a link failure is possible when both of the following situations occur:

  • A translation unit is compiled with ARM Compiler v5.05.
  • A second translation unit is compiled with ARM Compiler v5.04 or earlier.
  • The translation units instantiate or refer to a template with a non-type argument of lvalue of function type.

Example

file1.cpp

template <class T> struct A
{
    template <void (*PF)()> struct B {};
};
void ff();
// f is undefined if file1.cpp is compiled with 5.04 and file2 is
// compiled with 5.05, or vice versa.
template<class T> typename A<T>::template B<ff> f(T);
int main()
{
    f(1);
}
			

file2.cpp

template <class T> struct A
{
    template <void (*PF)()> struct B {};
};
void ff();
template<class T> typename A<T>::template B<ff> f(T)
{
    typename A<T>::template B<ff> ret;
    return ret;
}
template A<int>::B<ff> f<int>(int);
			
Non-ConfidentialPDF file icon PDF versionARM DUI0530M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.