This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/71913 (copy elision choices)


Hi Jason,

On 22/07/16 04:01, Jason Merrill wrote:
71913 is a case where unsafe_copy_elision_p was being too
conservative. We can allow copy elision in a new expression; the only
way we could end up initializing a base subobject without knowing it
would be through a placement new, in which case we would already be
using the wrong (complete object) constructor, so copy elision doesn't
make it any worse.


diff --git a/gcc/testsuite/g++.dg/init/elide5.C b/gcc/testsuite/g++.dg/init/elide5.C
new file mode 100644
index 0000000..0a9978c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/elide5.C
@@ -0,0 +1,27 @@
+// PR c++/71913
+// { dg-do link { target c++11 } }
+
+void* operator new(unsigned long, void* p) { return p; }

g++.dg/init/elide5.C fails on target whose SIZE_TYPE is not "long unsigned int".

testsuite/g++.dg/init/elide5.C:4:42: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter [-fpermissive]

I have checked, for most 32 bit architectures or ABI, the SIZE_TYPE is "unsigned int". arm is one of them.

To make this test case portable, will __SIZE_TYPE__ be better in this case, instead of "unsigned long" as first argument of new operator?

(sorry for the duplicate reply in the bugzilla, I just found the email here)

Regards,
Renlin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]