Bug 115744

Summary: [C++26] P2747R2 - constexpr placement new
Product: gcc Reporter: Jakub Jelinek <jakub>
Component: c++Assignee: Jakub Jelinek <jakub>
Status: ASSIGNED ---    
Severity: normal CC: daniel.kruegler, jason, redi, webrown.cpp
Priority: P3    
Version: 15.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2024-07-02 00:00:00
Bug Depends on:    
Bug Blocks: 110338, 115754    
Attachments: gcc15-pr115744-wip.patch
gcc15-pr115744.patch

Description Jakub Jelinek 2024-07-02 08:41:39 UTC
See <https://wg21.link/P2747R2>.
Comment 1 Jakub Jelinek 2024-07-02 14:01:28 UTC
Created attachment 58563 [details]
gcc15-pr115744-wip.patch

Untested WIP patch.
Comment 2 Jason Merrill 2024-07-02 14:10:35 UTC
(In reply to Jakub Jelinek from comment #1)
> Untested WIP patch.

In the conversion lval change, I'd think we want vc_discard for conversion to void, and to pass through whatever lval for VIEW_CONVERT_EXPR.
Comment 3 Jakub Jelinek 2024-07-03 09:45:38 UTC
Created attachment 58580 [details]
gcc15-pr115744.patch

With the PR115754 change in, this seems mostly about the FTMs and making placement new constexpr.
The only thing that doesn't work is the
new (p + 1) int[]{2, 3};      // error (in this paper)
case from the paper xfailed in the last testcase, the IL has there
<<< 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 so there is nothing that would trigger some error during constexpr evaluation.
Shouldn't build_new_1 for maybe_constexpr_fn (current_function_decl) in the array_p case add some extra cast to the array type it is looking for rather
than just the ultimate element type?