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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
p debug_tree (dummy)
 <nop_expr 0x7fffe91ab380
    type <void_type 0x7fffea0610a8 void type_6 VOID
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea0610a8
        pointer_to_this <pointer_type 0x7fffea061150>>
    side-effects
    arg:0 <call_expr 0x7fffe917baf0
        type <pointer_type 0x7fffea061150 type <void_type 0x7fffea0610a8 void>
            public unsigned type_6 SI
            size <integer_cst 0x7fffea0501c8 constant 32>
            unit-size <integer_cst 0x7fffea0501e0 constant 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea061150
            pointer_to_this <pointer_type 0x7fffea06b1f8> reference_to_this
<reference_type 0x7fffe9997dc8>>
        side-effects nothrow
        fn <addr_expr 0x7fffe91ab360 type <pointer_type 0x7fffe970b5e8>
            constant arg:0 <function_decl 0x7fffe96d3000 __dt_comp >>
        arg:0 <addr_expr 0x7fffe91ab340 type <pointer_type 0x7fffe96d1888>
            arg:0 <var_decl 0x7fffe98f4c60 Fs>>
        ./example.cpp:317:1 start: ./example.cpp:317:1 finish:
./example.cpp:317:1>
    ./example.cpp:317:1 start: ./example.cpp:317:1 finish: ./example.cpp:317:1>
$1 = void

Guess the nop in there is added because of targetm.cxx.cdtor_returns_this.
The NOP_EXPR is created by:
              else if (call != error_mark_node
                       && DECL_DESTRUCTOR_P (cand->fn)
                       && !VOID_TYPE_P (TREE_TYPE (call)))
                /* An explicit call of the form "x->~X()" has type
                   "void".  However, on platforms where destructors
                   return "this" (i.e., those where
                   targetm.cxx.cdtor_returns_this is true), such calls
                   will appear to have a return value of pointer type
                   to the low-level call machinery.  We do not want to
                   change the low-level machinery, since we want to be
                   able to optimize "delete f()" on such platforms as
                   "operator delete(~X(f()))" (rather than generating
                   "t = f(), ~X(t), operator delete (t)").  */
                call = build_nop (void_type_node, call);

Reply via email to