<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 - Can't jump into scope of a variable with a nontrivial destructor in C++20"
href="https://bugs.llvm.org/show_bug.cgi?id=52416">52416</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Can't jump into scope of a variable with a nontrivial destructor in C++20
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>13.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>Keywords</th>
<td>compile-fail
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>josephcsible@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The C++17 standard says "A program that jumps from a point where a variable
with automatic storage duration is not in scope to a point where it is in scope
is ill-formed unless the variable has scalar type, class type with a trivial
default constructor and a trivial destructor, a cv-qualified version of one of
these types, or an array of one of the preceding types and is declared without
an initializer (11.6)."
The C++20 standard says "A program that jumps from a point where a variable
with automatic storage duration is not in scope to a point where it is in scope
is ill-formed unless the variable has vacuous initialization (6.7.3)." and "A
variable is said to have vacuous initialization if it is default-initialized
and, if it is of class type or a (possibly multi-dimensional) array thereof,
that class type has a trivial default constructor."
Note that the C++17 standard mentions a trivial destructor here, but the C++20
standard does not. Now consider this code:
struct MyStruct {
~MyStruct() {}
};
void foo() {
goto x;
MyStruct s;
x:
return;
}
It's ill-formed in C++17, but fine in C++20. However, we currently reject this
program even with -std=c++20.</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>