llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Itanium ABI: incorrect mangling of unresolved operator name

Open wolfy1961 opened this issue 11 years ago • 4 comments

Bugzilla Link 22584
Resolution FIXED
Resolved on Feb 25, 2015 11:40
Version trunk
OS Linux
CC @majnemer,@DougGregor

Extended Description

Given the following case:

struct S4 { S4 operator-(S4 rhs) { return rhs; } }; template auto kkk(T p)->decltype(&T::operator-){} template<> decltype(&S4::operator-) kkk(S4 x) { return nullptr; }

clang (r229188) mangles the explicit instantiation of kkk() as: Z3kkkI2S4EDTadsrT_miES1

when the correct mangling should be:

Z3kkkI2S4EDTadsrT_onmiES1 (note the additional "on")

The crux is here that T::operator- is an unresolved name and the ABI (chapter 5.1.5) gives the following:

::= # unresolved name ::= on # unresolved operator-function-id ::= on # unresolved operator template-id

and, later, in an example

      template<class T> auto f(T p)->decltype(&T::operator-);
        // The return type in the mangling of the template signature
        // is encoded as "DTadsrT_onmiE".

gcc 4.8.2 is inconsistent. With the above example, it matches clang's mangling, but with the following example

struct S4 { S4(int a) {} }; S4 operator+(S4 lhs, S4 rhs) { return rhs; } template auto g(T p1) -> decltype(operator+(p1,p1)); template <> auto g(S4 p1) -> decltype(operator+(p1,p1)) { return 0; }

gcc mangles the instantiation of g() correctly to: Z1gI2S4EDTclonplfp_fp_EET

whereas clang leaves out the "on" Z1gI2S4EDTclplfp_fp_EET

wolfy1961 avatar Feb 14 '15 03:02 wolfy1961

Fixed in r229255.

This revision is incorrect, it was r230512.

Wrong PR, sorry for the noise.

majnemer avatar Feb 25 '15 19:02 majnemer

Fixed in r229255.

This revision is incorrect, it was r230512.

majnemer avatar Feb 25 '15 19:02 majnemer

Fixed in r229255.

majnemer avatar Feb 14 '15 15:02 majnemer

assigned to @majnemer

wolfy1961 avatar Feb 14 '15 03:02 wolfy1961