<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 - Spurious "expression with side effects has no effect in an unevaluated context" warning when VLA"
href="https://bugs.llvm.org/show_bug.cgi?id=48666">48666</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Spurious "expression with side effects has no effect in an unevaluated context" warning when VLA
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>cuoq@trust-in-soft.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>Consider the C compilation unit:
int Y, Z;
void f(int n) {
long u[n];
Y = sizeof *(Z=1, &u);
}
Clang warns that the side-effect “Z=1” will have no effect because it's an
unevaluated context, but actually, u is a VLA, and in this case side-effects
happen. Note that the code generated by Clang is correct, it is only the
warning that should not be emitted:
<source>:5:14: warning: expression with side effects has no effect in an
unevaluated context [-Wunevaluated-expression]
Y = sizeof *(Z=1, &u);
^
1 warning generated.
Compiler returned: 0
Generated code with -O:
f: # @f
movl $1, Z(%rip)
shll $3, %edi
movl %edi, Y(%rip)
retq
Compiler Explorer link: <a href="https://gcc.godbolt.org/z/PG9cd9">https://gcc.godbolt.org/z/PG9cd9</a>
The relevant C17 clause: <a href="https://cigix.me/c17#6.5.3.4.p2">https://cigix.me/c17#6.5.3.4.p2</a></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>