Repository navigation
Segfault in do_constexpr_new on a new-expression with an empty placement list in C++20 mode #634
gwllx
started this conversation in
Issue Triage - Compilation
Replies: 1 comment
|
Possible fix: diff --git a/src/interpret.c b/src/interpret.c
index ccd274540c..5be52890e6 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -29037,7 +29037,9 @@ Evaluate the given new-expression.
already and we will have recorded the specific address and type that
the placement-new can access. */
an_expr_node_ptr ptr_expr = ndsp->arg;
- a_type_ptr ptr_tp = skip_typerefs(ptr_expr->type);
+ /* ptr_expr can be NULL for an empty placement list "new () int". */
+ a_type_ptr ptr_tp = ptr_expr != NULL ? skip_typerefs(ptr_expr->type)
+ : NULL;
if (type != valid_placement_new_type) {
/* The new-expression does not allocate a type deduced for an enclosing
std::construct_at<T> call. */ |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
Invalid code crashes the front end in C++20 and later modes after the expected
error: expected an expression. C++17 only reports the error without a segfault.Discovered running the gcc test
tests/tests/imported/gnu/cpp/parse/new-placement1.sft.cppin C++20 mode.Reproducing Source Code
https://godbolt.org/z/77zz4EP1E (
Compiler returned: 139with--c++20)Command-line Options
cpfe --c++20
Type of Issue
[Front End] This code SHOULD compile with these options.
Additional Details
do_constexpr_newcallsskip_typerefs(ptr_expr->type)before null checking.Reproducing (Standard) Configuration(s)
linux-gcc-release
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions