<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 ignores destructors with side-effects"
href="https://bugs.llvm.org/show_bug.cgi?id=45534">45534</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__builtin_constant_p ignores destructors with side-effects
</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>Given an expression that creates a temporary with a non-trivial destructor that
has side-effects, Clang still manages to evaluate `__builtin_constant_p` of
said expression to `1`.
I am not sure that it is clear whether `__builtin_constant_p` is considered a
full-expression context. I think not treating it as one is more conservative.
In either case though, calling or registering a destructor whose definition is
unknown can hardly be considered to not have side-effects.
### SOURCE (<stdin>):
struct S { ~S(); };
static_assert(!__builtin_constant_p((S{}, 42)), "");
### COMPILER INVOCATION:
clang -cc1 -fsyntax-only -xc++ -
### EXPECTED OUTPUT:
(clean compile)
### ACTUAL OUTPUT:
<stdin>:2:1: error: static_assert failed due to requirement
'!__builtin_constant_p((S{} , 42))' ""
static_assert(!__builtin_constant_p((S{}, 42)), "");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
### 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>