void fn1(bool = true) { (fn1)(); } Is accepted with c++11 but not with c++14. This is what creduce came up with. clang++ accepts this code though it warns: q.cc:1:23: warning: all paths through this function will call itself [-Winfinite-recursion]
So has it ever been accepted with -std=c++1y? Otherwise it would probably not be a regression...
(In reply to Jakub Jelinek from comment #1) > So has it ever been accepted with -std=c++1y? Otherwise it would probably > not be a regression... Yes, gcc-48 accepts this with -std=gnu++1y or -std=c++1y.
C++14's () is special.
(fn1)(); is no longer the same as fn1(); But rather it returns an rvalue reference. So it no longer includes the default arguments as part of the type. That is function types don't have default arguments.
In some contexts yes, but 5.1.1 [expr.prim.general] p6 says: A parenthesized expression is a primary expression whose type and value are identical to those of the enclosed expression. The presence of parentheses does not affect whether the expression is an lvalue. The parenthesized expression can be used in exactly the same contexts as those where the enclosed expression can be used, and with the same meaning, except as otherwise indicated. I don't see anything indicating otherwise in [conf.func] or [expr.call] or [dcl.fct.default].
Seems to only happen when fn1 is not overloaded. If it is overloaded then the code is accepted in C++14: void fn1(int, int); void fn1(bool = true) { (fn1)(); }
A patch is posted at: https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01587.html
Author: ppalka Date: Thu Feb 25 01:14:27 2016 New Revision: 233691 URL: https://gcc.gnu.org/viewcvs?rev=233691&root=gcc&view=rev Log: Fix PR c++/69736 gcc/cp/ChangeLog: PR c++/69736 * cp-tree.h (REF_PARENTHESIZED_P): Adjust documentation. (maybe_undo_parenthesized_ref): Declare. * semantics.c (maybe_undo_parenthesized_ref): Split out from check_return_expr. (finish_call_expr): Use it. * typeck.c (check_return_expr): Use it. * pt.c (tsubst_copy_and_build) [INDIRECT_REF]: Retain the REF_PARENTHESIZED_P flag. gcc/testsuite/ChangeLog: PR c++/69736 * g++.dg/cpp1y/paren2.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1y/paren2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/pt.c trunk/gcc/cp/semantics.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
Fixed for GCC 6.