public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892
@ 2023-11-21 21:46 julia.desmazes at gmail dot com
2023-11-21 22:23 ` [Bug c++/112658] [12/13/14 Regression] " pinskia at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: julia.desmazes at gmail dot com @ 2023-11-21 21:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Bug ID: 112658
Summary: ICE: finish_expr_stmt , at cp/semantics.cc:892
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: julia.desmazes at gmail dot com
Target Milestone: ---
Created attachment 56664
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56664&action=edit
preprocessed file ( ii )
Hello,
I have come across an internal compiler error when using g++ 13.2.1.
The error occurs when casting a temporary array into a pointer and forwarding
the result to a constructor.
Code to reproduce :
```
#include <stdint.h>
#include <iostream>
#include <cstring>
#define DEFAULT_DST_MAC ((uint8_t[6]) { 0xFC, 0xFC, 0x48, 0, 0, 0})
class foo{
public:
foo(const uint8_t new_mac[6]){
std::cout << new_mac << std::endl;
memcpy(&this->mac, new_mac, 6);
}
private:
uint8_t mac[6];
};
int main(){
foo f((uint8_t*)DEFAULT_DST_MAC);
return 0;
}
```
Console log for `g++ -v -c main.cpp -freport-bug -save-temps` :
```
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --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-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20230801 (GCC)
COLLECT_GCC_OPTIONS='-v' '-c' '-freport-bug' '-save-temps' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/cc1plus -E -quiet -v -D_GNU_SOURCE
main.cpp -mtune=generic -march=x86-64 -freport-bug -fpch-preprocess -o main.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include-fixed
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-c' '-freport-bug' '-save-temps' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/cc1plus -fpreprocessed main.ii -quiet
-dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -version
-freport-bug -o main.s
GNU C++17 (GCC) version 13.2.1 20230801 (x86_64-pc-linux-gnu)
compiled by GNU C version 13.2.1 20230801, GMP version 6.3.0, MPFR
version 4.2.0-p12, MPC version 1.3.1, isl version isl-0.26-GMP
warning: MPFR header version 4.2.0-p12 differs from library version 4.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5a490a353c29b926850bca65a518c219
main.cpp: In function ‘int main()’:
main.cpp:18:68: internal compiler error: in finish_expr_stmt, at
cp/semantics.cc:892
18 | foo f((uint8_t*)DEFAULT_DST_MAC);
| ^
0x1ad33c8 internal_error(char const*, ...)
???:0
0x6b7b63 fancy_abort(char const*, int, char const*)
???:0
0x76527f cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x9443d0 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
Preprocessed source stored into /tmp/ccJZigsM.out file, please attach this to
your bugreport.
make: *** [makefile:10: main.o] Error 1
```
If needed, the `ccJZigsM.out` file can be found in the following git :
https://github.com/Essenceia/gcc_bug
I will be happy to provide any additional files if needed.
Regards,
Julia Desmazes
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt , at cp/semantics.cc:892
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
@ 2023-11-21 22:23 ` pinskia at gcc dot gnu.org
2023-11-21 22:26 ` [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer pinskia at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21 22:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
Target Milestone|--- |12.4
Summary|ICE: finish_expr_stmt , at |[12/13/14 Regression] ICE:
|cp/semantics.cc:892 |finish_expr_stmt , at
| |cp/semantics.cc:892
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-11-21
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
struct foo{
foo(const int *new_mac);
};
void g(){
foo f((int*)((int[1]){ 0xFC}));
}
```
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
2023-11-21 22:23 ` [Bug c++/112658] [12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-11-21 22:26 ` pinskia at gcc dot gnu.org
2023-11-21 22:35 ` [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call pinskia at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21 22:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13/14 Regression] ICE: |[12/13/14 Regression] ICE:
|finish_expr_stmt , at |finish_expr_stmt with
|cp/semantics.cc:892 |casting an temp array to
| |pointer
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a better testcase:
```
struct foo{
foo(const int *new_mac);
};
typedef int t[1];
void g(){
foo f((int*)t{ 0xFC});
}
```
Which is definitely valid code.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
2023-11-21 22:23 ` [Bug c++/112658] [12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-11-21 22:26 ` [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer pinskia at gcc dot gnu.org
@ 2023-11-21 22:35 ` pinskia at gcc dot gnu.org
2023-11-21 22:37 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21 22:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm GCC rejects:
```
struct foo{
foo(const int *new_mac);
};
typedef int t[1];
void g(){
foo f(t{ 0xFC});
}
```
While clang, MSVC all accepts it ...
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (2 preceding siblings ...)
2023-11-21 22:35 ` [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call pinskia at gcc dot gnu.org
@ 2023-11-21 22:37 ` pinskia at gcc dot gnu.org
2023-11-22 0:37 ` ppalka at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21 22:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=94264
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Hmm GCC rejects:
> ```
> struct foo{
> foo(const int *new_mac);
> };
> typedef int t[1];
>
> void g(){
> foo f(t{ 0xFC});
> }
> ```
> While clang, MSVC all accepts it ...
Oh wait that is PR 94264.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (3 preceding siblings ...)
2023-11-21 22:37 ` pinskia at gcc dot gnu.org
@ 2023-11-22 0:37 ` ppalka at gcc dot gnu.org
2023-12-04 22:15 ` [Bug c++/112658] [12/13 " ppalka at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-11-22 0:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
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
Keywords|needs-bisection |wrong-code
Status|NEW |ASSIGNED
CC| |ppalka at gcc dot gnu.org
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The ICE-on-valid started with r12-2233-gb9119edc09e466, but before that this
was wrong-code:
bool called;
struct foo{
foo(const int *new_mac) { called = true; }
};
typedef int t[1];
int main() {
foo f((int*)t{ 0xFC});
if (!called) __builtin_abort();
}
If we do copy initialization instead of direct initialization then we ICE ever
since the sanity check assert was added in r6-6795-g0fd9d4921f7ba2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (4 preceding siblings ...)
2023-11-22 0:37 ` ppalka at gcc dot gnu.org
@ 2023-12-04 22:15 ` ppalka at gcc dot gnu.org
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-12-04 22:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13/14 Regression] ICE: |[12/13 Regression] ICE:
|finish_expr_stmt with |finish_expr_stmt with
|casting an temp array to |casting an temp array to
|pointer and constructor |pointer and constructor
|call |call
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
GCC trunk accepts (and correctly compiles) the testcase after the r14-5941 fix
for PR94264.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (5 preceding siblings ...)
2023-12-04 22:15 ` [Bug c++/112658] [12/13 " ppalka at gcc dot gnu.org
@ 2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-08 18:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
--- Comment #7 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:5764825aed613f201a8bc47e5b239027a39691f0
commit r14-6342-g5764825aed613f201a8bc47e5b239027a39691f0
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Dec 8 13:33:55 2023 -0500
c++: undiagnosed error_mark_node from cp_build_c_cast [PR112658]
When cp_build_c_cast commits to an erroneous const_cast, we neglect to
replay errors from build_const_cast_1 which can lead to us incorrectly
accepting (and "miscompiling") the cast, or triggering the assert in
finish_expr_stmt.
This patch fixes this oversight. This was the original fix for the ICE
in PR112658 before r14-5941-g305a2686c99bf9 made us accept the testcase
there after all. I wasn't able to come up with an alternate testcase for
which this fix has an effect anymore, but below is a reduced version of
the PR112658 testcase (accepted ever since r14-5941) for good measure.
PR c++/112658
PR c++/94264
gcc/cp/ChangeLog:
* typeck.cc (cp_build_c_cast): If we're committed to a const_cast
and the result is erroneous, call build_const_cast_1 a second
time to issue errors. Use complain=tf_none instead of =false.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-array20.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (6 preceding siblings ...)
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
@ 2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2024-05-13 11:29 ` rguenth at gcc dot gnu.org
2024-05-13 16:26 ` ppalka at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-08 18:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
--- Comment #8 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:0c018a74eb1affe2a1fa385cdddaa93979683420
commit r14-6343-g0c018a74eb1affe2a1fa385cdddaa93979683420
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Dec 8 13:34:04 2023 -0500
c++: guard more against undiagnosed error_mark_node [PR112658]
This adds a sanity check to cp_parser_expression_statement similar to
the one in finish_expr_stmt added by r6-6795-g0fd9d4921f7ba2, which
effectively downgrades accepts-invalid/wrong-code bugs like this one
into ice-on-invalid/ice-on-valid ones.
PR c++/112658
gcc/cp/ChangeLog:
* parser.cc (cp_parser_expression_statement): If the statement
is error_mark_node, make sure we've seen_error().
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (7 preceding siblings ...)
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
@ 2024-05-13 11:29 ` rguenth at gcc dot gnu.org
2024-05-13 16:26 ` ppalka at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-13 11:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/112658] [12/13 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
` (8 preceding siblings ...)
2024-05-13 11:29 ` rguenth at gcc dot gnu.org
@ 2024-05-13 16:26 ` ppalka at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-13 16:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112658
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|12.4 |14.0
Status|ASSIGNED |RESOLVED
--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Not backporting any of these fixes since this never properly worked -- it was
either wrong-code, rejects-valid or (most recently) ice-on-valid -- and so not
really a regression.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-05-13 16:26 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21 21:46 [Bug c++/112658] New: ICE: finish_expr_stmt , at cp/semantics.cc:892 julia.desmazes at gmail dot com
2023-11-21 22:23 ` [Bug c++/112658] [12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-11-21 22:26 ` [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer pinskia at gcc dot gnu.org
2023-11-21 22:35 ` [Bug c++/112658] [12/13/14 Regression] ICE: finish_expr_stmt with casting an temp array to pointer and constructor call pinskia at gcc dot gnu.org
2023-11-21 22:37 ` pinskia at gcc dot gnu.org
2023-11-22 0:37 ` ppalka at gcc dot gnu.org
2023-12-04 22:15 ` [Bug c++/112658] [12/13 " ppalka at gcc dot gnu.org
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2024-05-13 11:29 ` rguenth at gcc dot gnu.org
2024-05-13 16:26 ` 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).