When the sample code snippet (below) is compiled, errors (below) occur.  This
issue breaks the compilation of wxWidgets' Media Library.  The same problem
occurs with the latest snapshot (20060331, used in the example below) of GCC
4.1.1, on both CygWin and MinGW.

The sample code (virt-test.ii):

# 1 "virt-test.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "virt-test.cpp"
struct top
{
  virtual ~top() {}
  virtual int __attribute__((__stdcall__)) fun1() = 0;
  virtual char __attribute__((__stdcall__)) fun2() = 0;
  virtual double __attribute__((__stdcall__)) fun3() = 0;
};

struct mid1 : public top
{
  virtual int __attribute__((__stdcall__)) fun1() = 0;
  virtual char __attribute__((__stdcall__)) fun2() = 0;
  virtual double __attribute__((__stdcall__)) fun3() = 0;
  virtual long __attribute__((__stdcall__)) fun4() = 0;
};

struct mid2 : public top
{
  virtual int __attribute__((__stdcall__)) fun1() = 0;
  virtual char __attribute__((__stdcall__)) fun2() = 0;
  virtual double __attribute__((__stdcall__)) fun3() = 0;
  virtual long __attribute__((__stdcall__)) fun5() = 0;
};

struct mid3 : public top
{
  virtual int __attribute__((__stdcall__)) fun1() = 0;
  virtual char __attribute__((__stdcall__)) fun2() = 0;
  virtual double __attribute__((__stdcall__)) fun3() = 0;
  virtual long __attribute__((__stdcall__)) fun6() = 0;
};

struct bottom : public mid1, public mid2, public mid3
{
  int __attribute__((__stdcall__)) fun1();
  char __attribute__((__stdcall__)) fun2();
  double __attribute__((__stdcall__)) fun3();

  long __attribute__((__stdcall__)) fun4()
  { return 345L; }

  long __attribute__((__stdcall__)) fun5()
  { return 456L; }

  long __attribute__((__stdcall__)) fun6()
  { return 567L; }
};

int __attribute__((__stdcall__)) bottom::fun1()
{ return 123; }

char __attribute__((__stdcall__)) bottom::fun2()
{ return 'a'; }

double __attribute__((__stdcall__)) bottom::fun3()
{ return 123.45; }

int main()
{
  bottom b;
  b.fun1();
  b.fun2();
  b.fun3();
  b.fun4();
  b.fun5();
  b.fun6();
}

The command line to compile:

mingw32-g++ -v -save-temps -Wall -Wextra -pedantic -o virt-test.exe virt-test
.cpp

And compiler output:

Using built-in specs.
Target: mingw32
Configured with:
/usr/local/src/gcc/build-cross/source/gcc-4.1-20060331//configure -v
--prefix=/usr/local/cross-mingw-4.1 --target=mingw32
--with-headers=/usr/local/cross-mingw-4.1/mingw32/include --with-gcc
--with-gnu-ld --with-gnu-as --enable-threads=win32 --disable-nls
--enable-languages=c,c++ --disable-win32-registry --disable-shared
--enable-sjlj-exceptions --enable-libstdcxx-allocator=pool --without-newlib
Thread model: win32
gcc version 4.1.1 20060331 (prerelease)
 /usr/local/cross-mingw-4.1/libexec/gcc/mingw32/4.1.1/cc1plus.exe -E -quiet -v
virt-test.cpp -Wall -Wextra -pedantic -fpch-preprocess -o virt-test.ii
ignoring nonexistent directory
"/usr/local/cross-mingw-4.1/lib/gcc/mingw32/4.1.1/../../../../mingw32/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/cross-mingw-4.1/lib/gcc/mingw32/4.1.1/../../../../include/c++/4.1.1

/usr/local/cross-mingw-4.1/lib/gcc/mingw32/4.1.1/../../../../include/c++/4.1.1/mingw32

/usr/local/cross-mingw-4.1/lib/gcc/mingw32/4.1.1/../../../../include/c++/4.1.1/backward
 /usr/local/cross-mingw-4.1/lib/gcc/mingw32/4.1.1/include
 /usr/local/cross-mingw-4.1/lib/gcc/mingw32/4.1.1/../../../../mingw32/include
End of search list.
 /usr/local/cross-mingw-4.1/libexec/gcc/mingw32/4.1.1/cc1plus.exe
-fpreprocessed virt-test.ii -quiet -dumpbase virt-test.cpp -auxbase virt-test
-Wall -Wextra -pedantic -version -o virt-test.s
GNU C++ version 4.1.1 20060331 (prerelease) (mingw32)
        compiled by GNU C version 3.4.4 (cygming special) (gdc 0.12, using dmd
0.125).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ce3135ac5ab9fb49e72d849828fbe7dc
virt-test.cpp:66: error: 'char *LTHUNK2()' aliased to undefined symbol
'_ZN6bottom4fun2Ev'
virt-test.cpp:66: error: 'char *LTHUNK3()' aliased to undefined symbol
'_ZN6bottom4fun2Ev'
virt-test.cpp:66: error: 'double *LTHUNK4()' aliased to undefined symbol
'_ZN6bottom4fun3Ev'
virt-test.cpp:66: error: 'double *LTHUNK5()' aliased to undefined symbol
'_ZN6bottom4fun3Ev'


-- 
           Summary: Compile errors with multiple inheritance where the
                    stdcall attribute is applied to virtual functions.
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wszafran at users dot sourceforge dot net
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: mingw32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27067

Reply via email to