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

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

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

commit r15-2815-gafa3a4a52cf91485477e4aaa5f05987ec7ff869d
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu Aug 8 11:05:36 2024 +0200

    c++, libstdc++: Implement C++26 P2747R2 - constexpr placement new
[PR115744]

    With the PR115754 fix in, constexpr placement new mostly just works,
    so this patch just adds constexpr keyword to the placement new operators
    in <new>, adds FTMs and testsuite coverage.

    There is one accepts-invalid though, the
    new (p + 1) int[]{2, 3};      // error (in this paper)
    case from the paper.  Can we handle that incrementally?
    The problem with that is I think calling operator new now that it is
    constexpr should be fine even in that case in constant expressions, so
    int *p = std::allocator<int>{}.allocate(3);
    int *q = operator new[] (sizeof (int) * 2, p + 1);
    should be ok, so it can't be easily the placement new operator call
    itself on whose constexpr evaluation we try something special, it should
    be on the new expression, but constexpr.cc actually sees only
    <<< Unknown tree: expr_stmt
      (void) (TARGET_EXPR <D.2640, (void *) TARGET_EXPR <D.2641,
VIEW_CONVERT_EXPR<int *>(b) + 4>>, TARGET_EXPR <D.2642, operator new [] (8,
NON_LVALUE_EXPR <D.2640>)>,   int * D.2643;
      <<< Unknown tree: expr_stmt
        (void) (D.2643 = (int *) D.2642) >>>;
    and that is just fine by the preexisting constexpr evaluation rules.

    Should build_new_1 emit some extra cast for the array cases with placement
    new in maybe_constexpr_fn (current_function_decl) that the existing P2738
    code would catch?

    2024-08-08  Jakub Jelinek  <ja...@redhat.com>

            PR c++/115744
    gcc/c-family/
            * c-cppbuiltin.cc (c_cpp_builtins): Change __cpp_constexpr
            from 202306L to 202406L for C++26.
    gcc/testsuite/
            * g++.dg/cpp2a/construct_at.h (operator new, operator new[]):
            Use constexpr instead of inline if __cpp_constexpr >= 202406L.
            * g++.dg/cpp26/constexpr-new1.C: New test.
            * g++.dg/cpp26/constexpr-new2.C: New test.
            * g++.dg/cpp26/constexpr-new3.C: New test.
            * g++.dg/cpp26/feat-cxx26.C (__cpp_constexpr): Adjust expected
            value.
    libstdc++-v3/
            * libsupc++/new (__glibcxx_want_constexpr_new): Define before
            including bits/version.h.
            (_GLIBCXX_PLACEMENT_CONSTEXPR): Define.
            (operator new, operator new[]): Use it for placement new instead
            of inline.
            * include/bits/version.def (constexpr_new): New FTM.
            * include/bits/version.h: Regenerate.

Reply via email to