https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100502
Bug ID: 100502
Summary: ICE in enforce_access at cp/semantics.c:368
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: raffael at casagrande dot ch
Target Milestone: ---
Compile the following source file:
--------------------------------
#include <concepts>
template <class>
struct EnumeratorRange {
struct Iterator {
EnumeratorRange* range_;
friend auto operator==(const Iterator&, const Iterator& i) noexcept -> bool
{
return i.range_->end_reached_;
}
};
private:
bool end_reached_;
};
--------------------------------
with current trunk (V12.0.0 20210509) or with gcc 11.1 on Ubuntu 20.04 using
the command line "g++-11 -std=c++20 main.cc". This produces the following ICE:
Compiler stderr
<source>: In function 'bool operator==(const EnumeratorRange<
<template-parameter-1-1> >::Iterator&, const EnumeratorRange<
<template-parameter-1-1> >::Iterator&)':
<source>:9:24: internal compiler error: in enforce_access, at
cp/semantics.c:368
9 | return i.range_->end_reached_;
| ^~~~~~~~~~~~
0x1d07289 internal_error(char const*, ...)
???:0
0x6bddc3 fancy_abort(char const*, int, char const*)
???:0
0x97a0ba perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int,
access_failure_info*)
???:0
0x971ece lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
???:0
0x9ed934 finish_class_member_access_expr(cp_expr, tree_node*, bool, int)
???:0
0x8e4d1d c_parse_file()
???:0
0xa653b2 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
------------------------
See also https://godbolt.org/z/PeGMvKeqd