[llvm-bugs] [Bug 45535] New: __builtin_constant_p with statement expression leaks destructor calls

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 14 12:00:51 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45535

            Bug ID: 45535
           Summary: __builtin_constant_p with statement expression leaks
                    destructor calls
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Destructors associated with statement expressions within the operand of
__builtin_constant_p end up actually being called(!)

### SOURCE (<stdin>):
struct S { ~S(); };
int f(void) { return __builtin_constant_p(({S s; 42;})); }


### COMPILER INVOCATION:
clang -cc1 -xc++ - -O2 -S -o -


### ACTUAL OUTPUT:
        .text
        .file   "-"
        .globl  _Z1fv                   # -- Begin function _Z1fv
        .p2align        4, 0x90
        .type   _Z1fv, at function
_Z1fv:                                  # @_Z1fv
# %bb.0:                                # %entry
        pushq   %rax
        movq    %rsp, %rdi
        callq   _ZN1SD1Ev at PLT
        movl    $1, %eax
        popq    %rcx
        retq
.Lfunc_end0:
        .size   _Z1fv, .Lfunc_end0-_Z1fv
                                        # -- End function
        .ident  "clang version 11.0.0 (https://github.com/llvm/llvm-project.git
4d9f5f135fad9eafa78ded8589af99a593415102)"
        .section        ".note.GNU-stack","", at progbits


### EXPECTED OUTPUT:
(
Something without
        callq   _ZN1SD1Ev at PLT
)


### COMPILER VERSION INFO (clang -v):
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
4d9f5f135fad9eafa78ded8589af99a593415102)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200414/a7096100/attachment.html>


More information about the llvm-bugs mailing list