[Bug c++/56606] New: GCC refuses to emit long calls for operator new/delete on PowerPC

2013-03-12 Thread gcc at mrozekma dot com


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



 Bug #: 56606

   Summary: GCC refuses to emit long calls for operator new/delete

on PowerPC

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c++

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: g...@mrozekma.com





-mlongcall seems to have no effect on operator new and operator delete. For

example, given the code:



> extern void foo();

> void bar() {

> foo();

> new char;

> }



A normal run of GCC on PowerPC will generate the (abridged) assembly:



> bl _Z3foov

> bl _Znwj



Running GCC with the -mlongcall option generates:



> lis r9, _Z3foov@ha

> addi r9, r9, _Z3foov@l

> mtctr r9

> bctrl

> bl _Znwj



The branch to foo() was expanded as expected, but the branch to operator new is

still short. Calls to random libc and libstdc++ functions are all converted; so

far operator new and operator delete are the only ones I've seen that don't

work. This seems similar to bug 12769, but that was for generated functions



---



GCC build info:



> Target: ppc-redhat-linux

> Configured with: ./configure --prefix=/opt/gcc-4.7.2-ppc 
> --mandir=/opt/gcc-4.7.2-ppc/share/man --enable-shared --enable-threads=posix 
> --with-system-zlib --enable-languages=c,c++ --build=ppc-redhat-linux 
> --host=ppc-redhat-linux --target=ppc-redhat-linux

> gcc version 4.7.2 (GCC) 



Test compiled with:



> g++ -mlongcall -c -o test.o test.cpp


[Bug c++/56606] GCC refuses to emit long calls for operator new/delete on PowerPC

2013-03-14 Thread gcc at mrozekma dot com


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



--- Comment #1 from Michael Mrozek  2013-03-14 
20:20:22 UTC ---

I found that including any of the standard C++ headers (, ,

, etc.) works around this, as does forward-declaring the operator:



> void* operator new(std::size_t);