http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140916 seems to break ABI, e.g. 4.4 compiled digikam can't be linked against 4.3 compiled libraries. struct B { int b; }; B b; struct A { B *operator->() const { return &b; } A () {} }; A a; int foo () { return a->b; } is mangled as _ZNK1AptEv in g++ 4.3 and below, but as _ZNK1AdtEv in g++ 4.4.
I can confirm this bug on my system. [psilva@joana GCC]$ uname -a Linux joana 2.6.27.12-170.2.5.fc10.i686 #1 SMP Wed Jan 21 02:09:37 EST 2009 i686 i686 i386 GNU/Linux [psilva@joana GCC]$ g++ -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=i386-redhat-linux Thread model: posix gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) [psilva@joana GCC]$ g++-4.4 -v Using built-in specs. Target: i386-redhat-linux Configured with: ../trunk/configure --prefix=/opt/gcc-4.4 --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++ --with-cpu=generic --build=i386-redhat-linux Thread model: posix gcc version 4.4.0 20090204 (experimental) (GCC) [psilva@joana GCC]$ cat test.cpp struct B { int b; }; B b; struct A { B *operator->() const { return &b; } A () {} }; A a; int foo () { return a->b; } [psilva@joana GCC]$ g++ -c -o 43.o test.cpp [psilva@joana GCC]$ g++-4.4 -c -o 44.o test.cpp [psilva@joana GCC]$ nm 43.o 00000039 t _GLOBAL__I_b 00000000 T _Z3foov 00000016 t _Z41__static_initialization_and_destruction_0ii 00000000 W _ZN1AC1Ev 00000000 W _ZNK1AptEv 00000004 B a 00000000 B b [psilva@joana GCC]$ nm 44.o 00000039 t _GLOBAL__I_b 00000000 T _Z3foov 00000016 t _Z41__static_initialization_and_destruction_0ii 00000000 W _ZN1AC1Ev 00000000 W _ZNK1AdtEv U __gxx_personality_v0 00000004 B a 00000000 B b
Just doing: @@ -1111,12 +1111,18 @@ write_unqualified_name (const tree decl) else if (DECL_OVERLOADED_OPERATOR_P (decl)) { operator_name_info_t *oni; + enum tree_code code = DECL_OVERLOADED_OPERATOR_P (decl); + if (DECL_ASSIGNMENT_OPERATOR_P (decl)) oni = assignment_operator_name_info; else - oni = operator_name_info; + { + oni = operator_name_info; + if (code == COMPONENT_REF) + code = ARROW_EXPR; + } - write_string (oni[DECL_OVERLOADED_OPERATOR_P (decl)].mangled_name); + write_string (oni[(int) code].mangled_name); } else if (VAR_OR_FUNCTION_DECL_P (decl) && ! TREE_PUBLIC (decl) && DECL_NAMESPACE_SCOPE_P (decl) is sufficient for the mangling, but still operator. appears in dumps etc. instead of operator->, and I guess the name -> mangled name stuff in write_expression won't do the right thing either. So, either the operators.def change should be reverted and dt should use a different code from COMPONENT_REF (or no code at all and just write_string ("dt"). Or operator-> should be parsed and handled as operator with ARROW_EXPR code rather than COMPONENT_REF.
Created attachment 17242 [details] gcc44-pr39095.patch Patch I'm going to bootstrap/regtest. I think changing code for operator-> in all places is more risky than this. Jason, does this look ok?
Subject: Re: [4.4 Regression] Mangling changes break ABI OK. Jason
Subject: Bug 39095 Author: jakub Date: Wed Feb 4 16:50:22 2009 New Revision: 143933 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143933 Log: PR c++/39095 * operators.def: Use COMPONENT_REF code for ->/pt operator again, remove ./dt operator. * mangle.c (write_expression): Handle COMPONENT_REF after handling ADDR_EXPR, for COMPONENT_REF without ARROW_EXPR inside of it write_string ("dt") instead of using operators.def. * g++.dg/abi/mangle31.C: New test. Added: trunk/gcc/testsuite/g++.dg/abi/mangle31.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/mangle.c trunk/gcc/cp/operators.def trunk/gcc/testsuite/ChangeLog
Fixed.
*** Bug 39122 has been marked as a duplicate of this bug. ***