ABI: Mangling of reference temporaries

Jason Merrill jason_merrill at redhat.com
Tue Jul 17 23:01:35 UTC 2001


Consider:

  int f ();
  inline int g ()
  {
    static int &r = f ();
    return r;
  }

  int main ()
  {
    return g ();
  }

Since f() is not an lvalue, we need to create a temporary to bind to r,
with the same storage duration.  Furthermore, since there is no way to
refer to r itself, a compiler could easily optimize away all references to
r and just use the temporary variable directly.  So it seems to me that we
need to define the mangling of such a variable.

I would think that a special-name starting with 'G' or 'T' would make
sense; perhaps "GR"?

Similarly, we should clarify what name is used for the guard variable in
this initialization; currently g++ names the guard variable after the
temporary, but I would expect it to be named after the user-written
variable.

Thoughts?

Jason



More information about the cxx-abi-dev mailing list