[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 Jason Merrill changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|--- |14.0 --- Comment #7 from Jason Merrill --- Fixed for GCC 14.
[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Jason Merrill : https://gcc.gnu.org/g:1e27e7e0985e055b3d4ec92e93976b709fdbe425 commit r14-277-g1e27e7e0985e055b3d4ec92e93976b709fdbe425 Author: Jason Merrill Date: Wed Feb 1 17:00:48 2023 -0500 c++: unique friend shenanigans [PR69836] Normally we re-instantiate a function declaration when we start to instantiate the body in case of multiple declarations. In this wacky testcase, this causes a problem because the type of the w_counter parameter depends on its declaration not being in scope yet, so the name lookup only finds the previous declaration. This isn't a problem for member functions, since they aren't subject to argument-dependent lookup. So let's just skip the regeneration for hidden friends. PR c++/69836 gcc/cp/ChangeLog: * pt.cc (regenerate_decl_from_template): Skip unique friends. gcc/testsuite/ChangeLog: * g++.dg/template/friend76.C: New test.
[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 --- Comment #5 from Jason Merrill --- (In reply to Jason Merrill from comment #4) > Here, the > problem looks to be that we're re-calculating the type of w_counter inside > the function definition (where the current function is in the overload set) > rather than using the actual parameter type (which is calculated before the > current function is in the overload set). Ah, the actual problem is regenerate_decl_from_template changing the type of w_counter.
[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 Jason Merrill changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC||jason at gcc dot gnu.org Last reconfirmed||2023-02-01 --- Comment #4 from Jason Merrill --- (In reply to Andrew Pinski from comment #3) > (In reply to Andrew Pinski from comment #2) > > I wonder if this is just invalid code but no diagnostic required as state > > changes inside the scope of TemplateObject. > > That is it needs to be reinterpret it after the parsing and needs to same > inside the scope itself. Like types of the same name should stay the same if > used inside the class. I have not considered that rule to apply to additional overloads. Here, the problem looks to be that we're re-calculating the type of w_counter inside the function definition (where the current function is in the overload set) rather than using the actual parameter type (which is calculated before the current function is in the overload set).
[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #2) > I wonder if this is just invalid code but no diagnostic required as state > changes inside the scope of TemplateObject. That is it needs to be reinterpret it after the parsing and needs to same inside the scope itself. Like types of the same name should stay the same if used inside the class. Like: typedef int t; class y { typedef t u; typedef float t; }; Which GCC only handles currently: :5:17: error: declaration of 'typedef float y::t' changes meaning of 't' [-fpermissive] 5 | typedef float t; | ^ :1:13: note: 't' declared here as 'typedef int t' 1 | typedef int t; | ^
[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 --- Comment #2 from Andrew Pinski --- I wonder if this is just invalid code but no diagnostic required as state changes inside the scope of TemplateObject.
[Bug c++/69836] compilation error with constexpr in template types with redeclared methods
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69836 --- Comment #1 from Marek Polacek --- *** Bug 69837 has been marked as a duplicate of this bug. ***