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

            Bug ID: 115037
           Summary: Unused std::vector is not optimized away.
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hubicka at gcc dot gnu.org
  Target Milestone: ---

Compiling 
#include <vector>
void
test()
{
        std::vector<int> test;
        test.push_back (1);
}

leads to

_Z4testv:
.LFB1253:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        movl    $4, %edi
        call    _Znwm
        movl    $4, %esi
        movl    $1, (%rax)
        movq    %rax, %rdi
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        jmp     _ZdlPvm

while clang optimizes to:

_Z4testv:                               # @_Z4testv
        .cfi_startproc
# %bb.0:
        retq

Reply via email to