https://gcc.gnu.org/g:ad200708db0ab5d97b3bdcc8919f17a58cf930b2
commit ad200708db0ab5d97b3bdcc8919f17a58cf930b2 Author: Jason Merrill <ja...@redhat.com> Date: Thu Mar 20 09:55:40 2025 -0400 c++: fix return type of __cxa_bad_array_new_length We were lying about the return type, but that's not necessary; we already need to handle a COND_EXPR where one side is void for THROW_EXPR. This fixes an execution failure on nvptx: error: Prototype doesn't match for '__cxa_throw_bad_array_new_length' gcc/cp/ChangeLog: * init.cc (throw_bad_array_new_length): Returns void. (cherry picked from commit cb537f0d838bac376bfe5e6d765e19cd3af01031) Diff: --- gcc/cp/ChangeLog.omp | 5 +++++ gcc/cp/init.cc | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index ed923563941f..e37a4344ca47 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,5 +1,10 @@ 2025-03-25 Thomas Schwinge <tschwi...@baylibre.com> + Backported from trunk: + 2025-03-21 Jason Merrill <ja...@redhat.com> + + * init.cc (throw_bad_array_new_length): Returns void. + Backported from trunk: 2025-03-21 Thomas Schwinge <tschwi...@baylibre.com> diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index e622547a092f..12e7cecfc59f 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -2800,8 +2800,7 @@ diagnose_uninitialized_cst_or_ref_member (tree type, bool using_new, bool compla } /* Call __cxa_bad_array_new_length to indicate that the size calculation - overflowed. Pretend it returns sizetype so that it plays nicely in the - COND_EXPR. */ + overflowed. */ tree throw_bad_array_new_length (void) @@ -2813,7 +2812,7 @@ throw_bad_array_new_length (void) fn = get_global_binding (name); if (!fn) fn = push_throw_library_fn - (name, build_function_type_list (sizetype, NULL_TREE)); + (name, build_function_type_list (void_type_node, NULL_TREE)); } return build_cxx_call (fn, 0, NULL, tf_warning_or_error);