public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check)
@ 2024-08-10 5:45 iamanonymous.cs at gmail dot com
2024-08-10 5:56 ` [Bug c++/116320] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2024-08-10 5:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
Bug ID: 116320
Summary: ICE: Segmentation fault
(perform_or_defer_access_check)
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: iamanonymous.cs at gmail dot com
Target Milestone: ---
Target: x86_64
*******************************************************************************
The compiler produces a segfault during perform_or_defer_access_check when
compiling the provided code with the specified options.
The issue can also be reproduced on Compiler Explorer.
*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/gcc-set/gcc24-7-24/gccbin/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/gcc-set/gcc24-7-24/configure
--prefix=/home/gcc-set/gcc24-7-24/gccbin --enable-languages=c,c++,fortran,go
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240724 (experimental) (GCC)
*******************************************************************************
Program:
# cat 1.cpp
class b{ };
template<class Type> class c : public b{
c<Type>* A();
static c<Type>* d;
};
template<class Type> c<Type>* c<Type>::d;
template<class Type> c<Type>* c<Type>::A(){
if (d->b::State()) { }
return NULL;
}
*******************************************************************************
Command Lines:
# g++ 1.cpp -O3 -funroll-loops -fno-strict-aliasing -finline-functions
-fno-omit-frame-pointer -g3 -Wall -Wextra -Werror -Wconversion -Wformat
-Wmissing-declarations -Wshadow -Wstrict-prototypes -c
cc1plus: error: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC
but not for C++ [-Werror]
1.cpp: In member function ‘c<Type>* c<Type>::A()’:
1.cpp:10:13: internal compiler error: Segmentation fault
10 | if (d->b::State()) { }
| ^
0x27f432e internal_error(char const*, ...)
/home/gcc-set/gcc24-7-24/gcc/diagnostic-global-context.cc:491
0x1412bf6 crash_signal
/home/gcc-set/gcc24-7-24/gcc/toplev.cc:319
0xd2c40e perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int,
access_failure_info*)
/home/gcc-set/gcc24-7-24/gcc/cp/semantics.cc:489
0xc5e95d cp_parser_lookup_name
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:32367
0xc9ab27 cp_parser_class_name
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:26826
0xc946f0 cp_parser_qualifying_entity
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:7422
0xc946f0 cp_parser_nested_name_specifier_opt
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:7104
0xc97969 cp_parser_id_expression
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:6447
0xc9c6a9 cp_parser_postfix_dot_deref_expression
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:8684
0xc92051 cp_parser_postfix_expression
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:8221
0xc677d1 cp_parser_binary_expression
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:10415
0xc685a5 cp_parser_assignment_expression
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:10759
0xc68ae4 cp_parser_expression
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:10926
0xca6dac cp_parser_condition
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:14062
0xcb0376 cp_parser_selection_statement
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:13694
0xc76dba cp_parser_statement
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:12743
0xc79f8f cp_parser_statement_seq_opt
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:13451
0xc7a20f cp_parser_compound_statement
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:13298
0xca2585 cp_parser_function_body
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:26175
0xca2585 cp_parser_ctor_initializer_opt_and_function_body
/home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:26226
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
*******************************************************************************
Also ICE on trunk, compiler explorer:https://godbolt.org/z/9jns9j8hz
*******************************************************************************
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check)
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
@ 2024-08-10 5:56 ` pinskia at gcc dot gnu.org
2024-08-10 5:58 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-10 5:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |10.1.0, 10.5.0
Keywords|ice-on-invalid-code |ice-on-valid-code,
| |needs-bisection
Last reconfirmed| |2024-08-10
Summary|ICE: Segmentation fault |[12/13/14/15 Regression]
|(perform_or_defer_access_ch |ICE: Segmentation fault
|eck) |(perform_or_defer_access_ch
| |eck)
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Target Milestone|--- |12.5
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. This code can be made valid and we still ICE:
```
struct b{ void State(); };
template<class Type>
struct c : b
{
void A();
static c *d;
};
template<class Type> c<Type>* c<Type>::d;
template<class Type> void c<Type>::A(){
d->b::State();
}
void f()
{
c<int>::d->A();
}
```
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check)
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
2024-08-10 5:56 ` [Bug c++/116320] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
@ 2024-08-10 5:58 ` pinskia at gcc dot gnu.org
2024-08-13 13:23 ` [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350 ppalka at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-10 5:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Confirmed. This code can be made valid and we still ICE:
Note commenting out the definition of c<Type>::d and the code no longer ICEs.
That is commenting out:
```
template<class Type> c<Type>* c<Type>::d;
```
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
2024-08-10 5:56 ` [Bug c++/116320] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-08-10 5:58 ` pinskia at gcc dot gnu.org
@ 2024-08-13 13:23 ` ppalka at gcc dot gnu.org
2024-08-15 14:26 ` 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 @ 2024-08-13 13:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
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
CC| |ppalka at gcc dot gnu.org
Summary|[12/13/14/15 Regression] |[12/13/14/15 Regression]
|ICE: Segmentation fault |ICE: Segmentation fault
|(perform_or_defer_access_ch |(perform_or_defer_access_ch
|eck) |eck) since r11-1350
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
` (2 preceding siblings ...)
2024-08-13 13:23 ` [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350 ppalka at gcc dot gnu.org
@ 2024-08-15 14:26 ` cvs-commit at gcc dot gnu.org
2024-09-09 0:04 ` [Bug c++/116320] [12/13/14 " cvs-commit at gcc dot gnu.org
2024-09-09 0:06 ` [Bug c++/116320] [12/13 " ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-15 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
--- Comment #3 from GCC 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:484f139ccd3b631a777802e810a632678b42ffab
commit r15-2933-g484f139ccd3b631a777802e810a632678b42ffab
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Aug 15 10:23:54 2024 -0400
c++: c->B::m access resolved through current inst [PR116320]
Here when checking the access of (the injected-class-name) B in c->B::m
at parse time, we notice its context B (now the type) is a base of the
object type C<T>, so we proceed to use C<T> as the effective qualifying
type. But this C<T> is the dependent specialization not the primary
template type, so it has empty TYPE_BINFO, which leads to a segfault later
from perform_or_defer_access_check.
The reason the DERIVED_FROM_P (B, C<T>) test guarding this code path works
despite C<T> having empty TYPE_BINFO is because of its currently_open_class
logic (added in r9-713-gd9338471b91bbe) which replaces a dependent
specialization with the primary template type if we're inside it. So the
safest fix seems to be to call currently_open_class in the caller as well.
PR c++/116320
gcc/cp/ChangeLog:
* semantics.cc (check_accessibility_of_qualified_id): Try
currently_open_class when using the object type as the
effective qualifying type.
gcc/testsuite/ChangeLog:
* g++.dg/template/access42.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/116320] [12/13/14 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
` (3 preceding siblings ...)
2024-08-15 14:26 ` cvs-commit at gcc dot gnu.org
@ 2024-09-09 0:04 ` cvs-commit at gcc dot gnu.org
2024-09-09 0:06 ` [Bug c++/116320] [12/13 " ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-09 0:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:149d87fbe661da29d8a0aa671b42bd532206a8b8
commit r14-10656-g149d87fbe661da29d8a0aa671b42bd532206a8b8
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Aug 15 10:23:54 2024 -0400
c++: c->B::m access resolved through current inst [PR116320]
Here when checking the access of (the injected-class-name) B in c->B::m
at parse time, we notice its context B (now the type) is a base of the
object type C<T>, so we proceed to use C<T> as the effective qualifying
type. But this C<T> is the dependent specialization not the primary
template type, so it has empty TYPE_BINFO, which leads to a segfault later
from perform_or_defer_access_check.
The reason the DERIVED_FROM_P (B, C<T>) test guarding this code path works
despite C<T> having empty TYPE_BINFO is because of its currently_open_class
logic (added in r9-713-gd9338471b91bbe) which replaces a dependent
specialization with the primary template type if we're inside it. So the
safest fix seems to be to call currently_open_class in the caller as well.
PR c++/116320
gcc/cp/ChangeLog:
* semantics.cc (check_accessibility_of_qualified_id): Try
currently_open_class when using the object type as the
effective qualifying type.
gcc/testsuite/ChangeLog:
* g++.dg/template/access42.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 484f139ccd3b631a777802e810a632678b42ffab)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/116320] [12/13 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
` (4 preceding siblings ...)
2024-09-09 0:04 ` [Bug c++/116320] [12/13/14 " cvs-commit at gcc dot gnu.org
@ 2024-09-09 0:06 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-09-09 0:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116320
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13/14 Regression] ICE: |[12/13 Regression] ICE:
|Segmentation fault |Segmentation fault
|(perform_or_defer_access_ch |(perform_or_defer_access_ch
|eck) since r11-1350 |eck) since r11-1350
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.3 / 15 so far.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-09-09 0:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-10 5:45 [Bug c++/116320] New: ICE: Segmentation fault (perform_or_defer_access_check) iamanonymous.cs at gmail dot com
2024-08-10 5:56 ` [Bug c++/116320] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-08-10 5:58 ` pinskia at gcc dot gnu.org
2024-08-13 13:23 ` [Bug c++/116320] [12/13/14/15 Regression] ICE: Segmentation fault (perform_or_defer_access_check) since r11-1350 ppalka at gcc dot gnu.org
2024-08-15 14:26 ` cvs-commit at gcc dot gnu.org
2024-09-09 0:04 ` [Bug c++/116320] [12/13/14 " cvs-commit at gcc dot gnu.org
2024-09-09 0:06 ` [Bug c++/116320] [12/13 " ppalka 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).