[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555 Andrew Pinski changed: What|Removed |Added CC||terryinzaghi at 163 dot com --- Comment #6 from Andrew Pinski --- *** Bug 121172 has been marked as a duplicate of this bug. ***
[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555 Jason Merrill changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #5 from Jason Merrill --- Fixed for 15.2/16.
[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555 --- Comment #4 from GCC Commits --- The releases/gcc-15 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:e4940c042b753457748e2257a8b13ca3738b4fac commit r15-9808-ge4940c042b753457748e2257a8b13ca3738b4fac Author: Jason Merrill Date: Fri Jun 6 10:26:28 2025 -0400 c++: recursive template with deduced return [PR120555] Here since r15-4120 we were prematurely complaining about the use of func within its own definiton, which is fine at instantiation time. So don't require this for function templates that are currently being defined. But keep the error for instantiations of templates that are not currently being defined, which we similarly did not diagnose before r15-4120 but other implementations do. Both of these follow the general principle from [temp.res.general]/6 that we only error in a template body if no instatiation could be well-formed. Also remove a redundant call to require_deduced_type. PR c++/120555 gcc/cp/ChangeLog: * decl2.cc (fn_being_defined, fn_template_being_defined): New. (mark_used): Check fn_template_being_defined. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if39.C: New test. (cherry picked from commit 8d204f2a536f7253e4251aca7bc12af524800b4c)
[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555 --- Comment #3 from GCC Commits --- The trunk branch has been updated by Jason Merrill : https://gcc.gnu.org/g:8d204f2a536f7253e4251aca7bc12af524800b4c commit r16-1272-g8d204f2a536f7253e4251aca7bc12af524800b4c Author: Jason Merrill Date: Fri Jun 6 10:26:28 2025 -0400 c++: recursive template with deduced return [PR120555] Here since r15-4120 we were prematurely complaining about the use of func within its own definiton, which is fine at instantiation time. So don't require this for function templates that are currently being defined. But keep the error for instantiations of templates that are not currently being defined, which we similarly did not diagnose before r15-4120 but other implementations do. Both of these follow the general principle from [temp.res.general]/6 that we only error in a template body if no instatiation could be well-formed. Also remove a redundant call to require_deduced_type. PR c++/120555 gcc/cp/ChangeLog: * decl2.cc (fn_being_defined, fn_template_being_defined): New. (mark_used): Check fn_template_being_defined. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if39.C: New test.
[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555 Jason Merrill changed: What|Removed |Added Last reconfirmed||2025-06-06 Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org Ever confirmed|0 |1
[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555
--- Comment #2 from Patrick Palka ---
The comment #1 testcase might be over-reduced, it's more interesting if the two
branches of the constexpr have different return types:
// PR c++/120555
// { dg-do compile { target c++17 } }
struct A { int m; };
template
constexpr auto f() {
if constexpr (__is_same(T, int))
return 1;
else
return A{f()};
}
static_assert(f().m == 1);
static_assert(f() == 1);
[Bug c++/120555] [15/16 Regression] Use of auto func before deduction of auto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555
Patrick Palka changed:
What|Removed |Added
CC||jason at gcc dot gnu.org,
||ppalka at gcc dot gnu.org
Summary|[15 Regression] Use of auto |[15/16 Regression] Use of
|func before deduction of|auto func before deduction
|auto|of auto
--- Comment #1 from Patrick Palka ---
Started with r15-4120 "c++: require_deduced_type and modules".
// PR c++/120555
// { dg-do compile { target c++17 } }
template
constexpr auto f() {
if constexpr (__is_same(T, int)) {
return 1;
} else {
return f() + 1;
}
}
static_assert(f() == 2);
