[Bug c++/122789] [modules] ICE on invalid when tsubsting a parameter

2025-11-25 Thread nshead at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122789

Nathaniel Shead  changed:

   What|Removed |Added

   Target Milestone|--- |15.3
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |nshead at gcc dot 
gnu.org
 Status|NEW |RESOLVED

--- Comment #4 from Nathaniel Shead  ---
Fixed for 16/15.3.

[Bug c++/122789] [modules] ICE on invalid when tsubsting a parameter

2025-11-25 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122789

--- Comment #3 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Nathaniel Shead
:

https://gcc.gnu.org/g:dabaca84b2bce49d2c5e9c98f88cf13ea61a7604

commit r15-10552-gdabaca84b2bce49d2c5e9c98f88cf13ea61a7604
Author: Nathaniel Shead 
Date:   Sun Nov 23 23:24:39 2025 +1100

c++/modules: Stream all REQUIRES_EXPR_PARMS [PR122789]

We don't generally stream the TREE_CHAIN of a DECL, as this would cause
us to unnecessarily walk into the next member in its scope chain any
time it was referenced by an expression.

Unfortunately, REQUIRES_EXPR_PARMS is a tree chain of PARM_DECLs, so we
were only ever streaming the first parameter.  This meant that when a
parameter's type could not be tsubst'd we would ICE instead of returning
false.

This patch special-cases REQUIRES_EXPR to always stream the chain of
decls in its first operand.  As a drive-by improvement we also remove a
fixme about checking uncontexted PARM_DECLs.

PR c++/122789

gcc/cp/ChangeLog:

* module.cc (trees_out::core_vals): Treat REQUIRES_EXPR
specially and stream the chained decls of its first operand.
(trees_in::core_vals): Likewise.
(trees_out::tree_node): Check the PARM_DECLs we see are what we
expect.

gcc/testsuite/ChangeLog:

* g++.dg/modules/concept-12_a.C: New test.
* g++.dg/modules/concept-12_b.C: New test.

Signed-off-by: Nathaniel Shead 
Reviewed-by: Jason Merrill 
(cherry picked from commit 53b4e1d951eaf5bbb2fcedfdd156d80a4160878a)

[Bug c++/122789] [modules] ICE on invalid when tsubsting a parameter

2025-11-25 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122789

--- Comment #2 from GCC Commits  ---
The master branch has been updated by Nathaniel Shead :

https://gcc.gnu.org/g:53b4e1d951eaf5bbb2fcedfdd156d80a4160878a

commit r16-5582-g53b4e1d951eaf5bbb2fcedfdd156d80a4160878a
Author: Nathaniel Shead 
Date:   Sun Nov 23 23:24:39 2025 +1100

c++/modules: Stream all REQUIRES_EXPR_PARMS [PR122789]

We don't generally stream the TREE_CHAIN of a DECL, as this would cause
us to unnecessarily walk into the next member in its scope chain any
time it was referenced by an expression.

Unfortunately, REQUIRES_EXPR_PARMS is a tree chain of PARM_DECLs, so we
were only ever streaming the first parameter.  This meant that when a
parameter's type could not be tsubst'd we would ICE instead of returning
false.

This patch special-cases REQUIRES_EXPR to always stream the chain of
decls in its first operand.  As a drive-by improvement we also remove a
fixme about checking uncontexted PARM_DECLs.

PR c++/122789

gcc/cp/ChangeLog:

* module.cc (trees_out::core_vals): Treat REQUIRES_EXPR
specially and stream the chained decls of its first operand.
(trees_in::core_vals): Likewise.
(trees_out::tree_node): Check the PARM_DECLs we see are what we
expect.

gcc/testsuite/ChangeLog:

* g++.dg/modules/concept-12_a.C: New test.
* g++.dg/modules/concept-12_b.C: New test.

Signed-off-by: Nathaniel Shead 
Reviewed-by: Jason Merrill 

[Bug c++/122789] [modules] ICE on invalid when tsubsting a parameter

2025-11-22 Thread nshead at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122789

Nathaniel Shead  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2025-11-23
 Status|UNCONFIRMED |NEW

--- Comment #1 from Nathaniel Shead  ---
Reduced:

  // a.cpp
  export module M;
  template  bool b = requires(int, typename T::U x) { x; };

  // b.cpp
  module M;
  bool x = b;

$ g++ -S -fmodules -fconcepts [ab].cpp

Interestingly, if we swap the order of the parameters in the requires clause
things work correctly.