Message ID | 1437865942-8025-1-git-send-email-patrick@parcs.ath.cx |
---|---|
State | New |
Headers | show |
On Sat, Jul 25, 2015 at 7:12 PM, Patrick Palka <patrick@parcs.ath.cx> wrote: > gcc/cp/ChangeLog: > > PR c++/66857 > * cvt.c (ocp_convert): Don't call scalar_constant_value when > converting to a class type. > > gcc/testsuite/ChangeLog: > > PR c++/66857 > * g++.dg/init/pr66857.C: New test. This fix was approved here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857#c5 Committed to mainline. Is it OK for the GCC 5 branch?
On 07/25/2015 04:16 PM, Patrick Palka wrote: > On Sat, Jul 25, 2015 at 7:12 PM, Patrick Palka <patrick@parcs.ath.cx> wrote: >> gcc/cp/ChangeLog: >> >> PR c++/66857 >> * cvt.c (ocp_convert): Don't call scalar_constant_value when >> converting to a class type. >> >> gcc/testsuite/ChangeLog: >> >> PR c++/66857 >> * g++.dg/init/pr66857.C: New test. > > This fix was approved here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857#c5 > > Committed to mainline. Is it OK for the GCC 5 branch? Yes, thanks. Jason
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 13bc1f7..6d4bd9a 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -687,7 +687,8 @@ ocp_convert (tree type, tree expr, int convtype, int flags, } /* FIXME remove when moving to c_fully_fold model. */ - e = scalar_constant_value (e); + if (!CLASS_TYPE_P (type)) + e = scalar_constant_value (e); if (error_operand_p (e)) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/init/pr66857.C b/gcc/testsuite/g++.dg/init/pr66857.C new file mode 100644 index 0000000..43b0927 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/pr66857.C @@ -0,0 +1,19 @@ +// PR c++/66857 +// { dg-do run } + +const int i = 0; + +struct Test +{ + Test (const int &rhs) + { + if (&rhs != &i) + __builtin_abort (); + } +}; + +int +main (void) +{ + Test test = i; +}