[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 Marek Polacek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #8 from Marek Polacek --- Fixed in 9.3 too.
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 --- Comment #7 from Marek Polacek --- Author: mpolacek Date: Thu Aug 15 18:33:43 2019 New Revision: 274546 URL: https://gcc.gnu.org/viewcvs?rev=274546=gcc=rev Log: PR c++/90473 - wrong code with nullptr in default argument. * call.c (null_ptr_cst_p): Update quote from the standard. * decl.c (check_default_argument): Don't return nullptr when the arg has side-effects. * g++.dg/cpp0x/nullptr42.C: New test. Added: branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp0x/nullptr42.C Modified: branches/gcc-9-branch/gcc/cp/ChangeLog branches/gcc-9-branch/gcc/cp/call.c branches/gcc-9-branch/gcc/cp/decl.c
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 --- Comment #6 from Marek Polacek --- Fixed on trunk, will backport to 9.3.
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 --- Comment #5 from Marek Polacek --- Author: mpolacek Date: Tue Aug 13 15:05:48 2019 New Revision: 274382 URL: https://gcc.gnu.org/viewcvs?rev=274382=gcc=rev Log: PR c++/90473 - wrong code with nullptr in default argument. * call.c (null_ptr_cst_p): Update quote from the standard. * decl.c (check_default_argument): Don't return nullptr when the arg has side-effects. * g++.dg/cpp0x/nullptr42.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/nullptr42.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 Marek Polacek changed: What|Removed |Added Keywords||patch --- Comment #4 from Marek Polacek --- https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00597.html
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 Marek Polacek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #3 from Marek Polacek --- I think checking TREE_SIDE_EFFECTS there should be enough.
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #2 from Marek Polacek --- This is where we lose the side-effect: check_default_argument 13174 /* Avoid redundant -Wzero-as-null-pointer-constant warnings at 13175 the call sites. */ 13176 if (TYPE_PTR_OR_PTRMEM_P (decl_type) 13177 && null_ptr_cst_p (arg)) 13178 return nullptr_node; Poking more...
[Bug c++/90473] gcc does not call function in comma operator for default argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90473 Richard Biener changed: What|Removed |Added Keywords||wrong-code Status|UNCONFIRMED |NEW Last reconfirmed||2019-05-15 Version|unknown |10.0 Ever confirmed|0 |1 Known to fail||10.0 --- Comment #1 from Richard Biener --- Confirmed, the side-effect is lost. It works when the RHS is not constant or with void f(); void b(int p = (f(), 0)); void z() { b(); }