https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123030

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:eef599adc2415ebf28c4295203dfd26f92ef9420

commit r16-6266-geef599adc2415ebf28c4295203dfd26f92ef9420
Author: Jakub Jelinek <[email protected]>
Date:   Fri Dec 19 10:13:45 2025 +0100

    c++: Reject array new with -fexceptions with deleted dtor [PR123030]

    For array new and -fexceptions, we only try to build cleanup if
    TYPE_HAS_NONTRIVIAL_DESTRUCTOR and so don't complain if the
    array element has trivial but deleted destructor.

    The following patch changes it to build the dtor whenever
    type_build_dtor_call but only registers it as cleanup if the cleanup
    has TREE_SIDE_EFFECTS.  build_vec_delete_1 has a special
    case for these type_build_dtor_call && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR
    cases where it does less work.

    Though, I wonder if we also shouldn't test whether the ctor isn't noexcept,
    then we wouldn't have to change the new4.C test.  Though, clang++ rejects
    that as well even when it has noexcept ctor.

    2025-12-19  Jakub Jelinek  <[email protected]>

            PR c++/123030
            * init.cc (build_vec_init): Call build_vec_delete_1 for
-fexceptions
            even if just type_build_dtor_call, not only when
            TYPE_HAS_NONTRIVIAL_DESTRUCTOR.  But register cleanups only
            for TYPE_HAS_NONTRIVIAL_DESTRUCTOR.

            * g++.dg/cpp0x/deleted18.C: New test.
            * g++.dg/cpp0x/new4.C: Expect an error.

Reply via email to