public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
@ 2022-05-31 23:23 northon_patrick3 at yahoo dot ca
2022-05-31 23:31 ` [Bug c++/105797] [11/12/13 Regression] " mpolacek at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: northon_patrick3 at yahoo dot ca @ 2022-05-31 23:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
Bug ID: 105797
Summary: Internal compiler error: Segmentation fault (
fn_type_unification ->
satisfaction_cache::satisfaction_cache ->
iterative_hash_template_arg )
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: northon_patrick3 at yahoo dot ca
Target Milestone: ---
Created attachment 53061
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53061&action=edit
Result from -freport-bug
The code:
```
#include <type_traits>
#include <concepts>
template <typename T_>
struct AStruct
{
using value_type = T_;
};
template <typename T_>
constexpr auto fc1(AStruct<T_> v)
requires std::integral<typename std::decay_t<decltype(v)>::value_type>
//requires std::integral<T_>
{ return v; }
template <typename T1_, typename T2_>
constexpr auto fc2(AStruct<T1_> v1, AStruct<T2_> v2)
requires std::integral<typename std::decay_t<decltype(v1)>::value_type>
{ return v1; }
void test(AStruct<int> v1, AStruct<int> v2)
{ fc2(v1, v2); }
void test2(AStruct<int> v)
{ fc1(v); }
```
The command line:
```
g++ -std=c++20 test.cpp
```
The error:
```
test.cpp: In substitution of ‘template<class T_> constexpr auto
fc1(AStruct<T_>) requires integral<typename
std::decay<decltype(v)>::type::value_type> [with T_ = int]’:
test.cpp:25:7: required from here
test.cpp:25:14: internal compiler error: Segmentation fault
25 | { fc1(v); }
| ~~~^~~
0x1ac4724 internal_error(char const*, ...)
???:0
0x7f1693 iterative_hash_template_arg(tree_node*, unsigned int)
???:0
0x6bf9da satisfaction_cache::satisfaction_cache(tree_node*, tree_node*,
sat_info)
???:0
0x81bbd4 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x69d051 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
???:0
0x836c31 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0x7eaa63 c_parse_file()
???:0
0x914adb c_common_parse_file()
???:0
```
It happens from GCC 11.1 and onward to GCC 13 at commit
271072ca259dd285e7723d9bf6da7295e4090dfa.
GCC is configured with:
```
configure --prefix=/opt/pat-gcc --libdir=/opt/pat-gcc/lib
--libexecdir=/opt/pat-gcc/lib --enable-languages=c,c++,lto --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/opt/pat-gcc/include/dlang/gdc
```
If I comment out either one of test or test2 functions, it compiles. If I
change either one of the requires clause to use T_ or T1_ instead of decltype,
it compiles. If I change either one of fc1 or fc2 to use auto instead of a
template<> clause, it compiles. So it seem to crash at a very specific
condition.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105797] [11/12/13 Regression] Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
@ 2022-05-31 23:31 ` mpolacek at gcc dot gnu.org
2022-05-31 23:45 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-31 23:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
Priority|P3 |P2
Summary|Internal compiler error: |[11/12/13 Regression]
|Segmentation fault ( |Internal compiler error:
|fn_type_unification -> |Segmentation fault (
|satisfaction_cache::satisfa |fn_type_unification ->
|ction_cache -> |satisfaction_cache::satisfa
|iterative_hash_template_arg |ction_cache ->
|) |iterative_hash_template_arg
| |)
Target Milestone|--- |11.4
Keywords| |ice-on-valid-code
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-05-31
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r11-4859-gd3fd75d8694800:
commit d3fd75d869480044213553000d2c9dc236a4f7af
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Nov 9 18:16:48 2020 -0500
c++: Consider only relevant template arguments in sat_hasher
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105797] [11/12/13 Regression] Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
2022-05-31 23:31 ` [Bug c++/105797] [11/12/13 Regression] " mpolacek at gcc dot gnu.org
@ 2022-05-31 23:45 ` mpolacek at gcc dot gnu.org
2022-06-01 13:17 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-31 23:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
// PR c++/105797
namespace std {
template <int __v> struct integral_constant {
static constexpr int value = __v;
};
template <typename _Tp> struct decay { typedef _Tp type; };
template <typename _Tp> using decay_t = typename decay<_Tp>::type;
template <typename>
constexpr bool is_integral_v = integral_constant<true>::value;
template <typename _Tp>
concept integral = is_integral_v<_Tp>;
} // namespace std
template <typename> struct AStruct { using value_type = int; };
template <typename T_>
void fc1(AStruct<T_> v) requires
std::integral<typename std::decay_t<decltype(v)>::value_type>;
template <typename T1_, typename T2_>
void fc2(AStruct<T1_> v1, T2_) requires
std::integral<typename std::decay_t<decltype(v1)>::value_type>;
AStruct<int> test_v1, test2_v;
int test_v2;
void test() { fc2(test_v1, test_v2); }
void test2() { fc1(test2_v); }
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105797] [11/12/13 Regression] Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
2022-05-31 23:31 ` [Bug c++/105797] [11/12/13 Regression] " mpolacek at gcc dot gnu.org
2022-05-31 23:45 ` mpolacek at gcc dot gnu.org
@ 2022-06-01 13:17 ` ppalka at gcc dot gnu.org
2022-06-03 13:09 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-06-01 13:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105797] [11/12/13 Regression] Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
` (2 preceding siblings ...)
2022-06-01 13:17 ` ppalka at gcc dot gnu.org
@ 2022-06-03 13:09 ` cvs-commit at gcc dot gnu.org
2022-06-03 13:32 ` [Bug c++/105797] [11/12 " ppalka at gcc dot gnu.org
2023-05-29 10:07 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-03 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:df4f95dbd4764ffc1e8270e5b3c0fd71b6724562
commit r13-980-gdf4f95dbd4764ffc1e8270e5b3c0fd71b6724562
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Jun 3 09:08:41 2022 -0400
c++: find_template_parameters and PARM_DECLs [PR105797]
As explained in r11-4959-gde6f64f9556ae3, the atom cache assumes two
equivalent expressions (according to cp_tree_equal) must use the same
template parameters (according to find_template_parameters). This
assumption turned out to not hold for TARGET_EXPR, which was addressed
by that commit.
But this assumption apparently doesn't hold for PARM_DECL either:
find_template_parameters walks its DECL_CONTEXT but cp_tree_equal by
default doesn't consider DECL_CONTEXT unless comparing_specializations
is set. Thus in the first testcase below, the atomic constraints of #1
and #2 are equivalent according to cp_tree_equal, but according to
find_template_parameters the former uses T and the latter uses both T
and U (surprisingly).
We could fix this assumption violation by setting comparing_specializations
in the atom_hasher, which would make cp_tree_equal return false for the
two atoms, but that seems overly pessimistic here. Ideally the atoms
should continue being considered equivalent and we instead fix
find_template_paremeters to return just T for #2's atom.
To that end this patch makes for_each_template_parm_r stop walking the
DECL_CONTEXT of a PARM_DECL. This should be safe to do because
tsubst_copy / tsubst_decl only substitutes the TREE_TYPE of a PARM_DECL
and doesn't bother substituting the DECL_CONTEXT, thus the only relevant
template parameters are those used in its type. any_template_parm_r is
currently responsible for walking its TREE_TYPE, but I suppose it now makes
sense for for_each_template_parm_r to do so instead.
In passing this patch also makes for_each_template_parm_r stop walking
the DECL_CONTEXT of a VAR_/FUNCTION_DECL since doing so after walking
DECL_TI_ARGS is redundant, I think.
I experimented with not walking DECL_CONTEXT for CONST_DECL, but the
second testcase below demonstrates it's necessary to walk it.
PR c++/105797
gcc/cp/ChangeLog:
* pt.cc (for_each_template_parm_r) <case FUNCTION_DECL, VAR_DECL>:
Don't walk DECL_CONTEXT.
<case PARM_DECL>: Likewise. Walk TREE_TYPE.
<case CONST_DECL>: Simplify.
(any_template_parm_r) <case PARM_DECL>: Don't walk TREE_TYPE.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-decltype4.C: New test.
* g++.dg/cpp2a/concepts-memfun3.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105797] [11/12 Regression] Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
` (3 preceding siblings ...)
2022-06-03 13:09 ` cvs-commit at gcc dot gnu.org
@ 2022-06-03 13:32 ` ppalka at gcc dot gnu.org
2023-05-29 10:07 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-06-03 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13 Regression] |[11/12 Regression] Internal
|Internal compiler error: |compiler error:
|Segmentation fault ( |Segmentation fault (
|fn_type_unification -> |fn_type_unification ->
|satisfaction_cache::satisfa |satisfaction_cache::satisfa
|ction_cache -> |ction_cache ->
|iterative_hash_template_arg |iterative_hash_template_arg
|) |)
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105797] [11/12 Regression] Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg )
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
` (4 preceding siblings ...)
2022-06-03 13:32 ` [Bug c++/105797] [11/12 " ppalka at gcc dot gnu.org
@ 2023-05-29 10:07 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.4 |11.5
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-05-29 10:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31 23:23 [Bug c++/105797] New: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) northon_patrick3 at yahoo dot ca
2022-05-31 23:31 ` [Bug c++/105797] [11/12/13 Regression] " mpolacek at gcc dot gnu.org
2022-05-31 23:45 ` mpolacek at gcc dot gnu.org
2022-06-01 13:17 ` ppalka at gcc dot gnu.org
2022-06-03 13:09 ` cvs-commit at gcc dot gnu.org
2022-06-03 13:32 ` [Bug c++/105797] [11/12 " ppalka at gcc dot gnu.org
2023-05-29 10:07 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).