<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - __builtin_constant_p with statement expression leaks destructor calls"
   href="https://bugs.llvm.org/show_bug.cgi?id=45535">45535</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__builtin_constant_p with statement expression leaks destructor calls
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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,@function
_Z1fv:                                  # @_Z1fv
# %bb.0:                                # %entry
        pushq   %rax
        movq    %rsp, %rdi
        callq   _ZN1SD1Ev@PLT
        movl    $1, %eax
        popq    %rcx
        retq
.Lfunc_end0:
        .size   _Z1fv, .Lfunc_end0-_Z1fv
                                        # -- End function
        .ident  "clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
4d9f5f135fad9eafa78ded8589af99a593415102)"
        .section        ".note.GNU-stack","",@progbits


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


### COMPILER VERSION INFO (clang -v):
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>