[cfe-commits] [PATCH] Constructor and Destructor mangling, along with improved Calling Convention handling for Windows.

Charles Davis cdavis at mymail.mines.edu
Mon Jan 24 10:28:02 PST 2011

On 1/24/11 11:01 AM, Douglas Gregor wrote:
> Also, a change like this really needs testing. Here's a fun case:
>   typedef void func_type(int);
>   struct X {
>     func_type f;
>   };
> presumably, "f" gets the thiscall calling convention because of its context, but then decltype(X::f) is different from func_type.
Let me save you the trouble:

Z:\Users\chip>cl /c test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42
for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.


Z:\Users\chip>dumpbin /symbols test.obj
Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file test.obj


000 006EC627 ABS    notype       Static       | @comp.id
001 00000001 ABS    notype       Static       | @feat.00
002 00000000 SECT1  notype       Static       | .drectve
    Section length   2F, #relocs    0, #linenums    0, checksum        0
004 00000000 SECT2  notype       Static       | .debug$S
    Section length   7D, #relocs    0, #linenums    0, checksum        0
006 00000000 SECT3  notype       Static       | .text
    Section length    D, #relocs    0, #linenums    0, checksum 564BACA5
008 00000000 SECT3  notype ()    External     | ?f at X@@QAEXH at Z (public:
void __thiscall X::f(int))

String Table Size = 0x11 bytes


          7D .debug$S
          2F .drectve
           D .text

In VC8, X::f() does indeed have the __thiscall convention. I'm willing
to bet that that's true of VC9 and VC10 as well.


More information about the cfe-commits mailing list