<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62413>62413</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Spurious error with -fincremental-extensions in clang 16
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cov-tprince
</td>
</tr>
</table>
<pre>
We recently started the process to upgrade our frontend to clang 16. However, we discovered a fairly serious regression when using `-fincremental-extensions`:
```
$ cat bad.cpp
struct S {
~S();
};
S::~S() {}
$ /opt/pkg/clang-16/bin/clang++ -c bad.cpp
$ /opt/pkg/clang-16/bin/clang++ -c -Xclang -fincremental-extensions bad.cpp
bad.cpp:4:4: error: call to non-static member function without an object argument
S::~S() {}
~~~^
1 error generated.
$
```
Godbolt link for the above:
https://godbolt.org/z/89jfE3YWP
It's probably worth a little explanation for why we're using this obscure feature--this is an unfortunate wart relating to constraints imposed by our internal AST. When a type contains a member function template that implements a special member function (e.g. `operator=`) we attempt to instantiate those methods when doing AST translation even if they are not explicitly required by the translation unit. Any errors generated by this instantiation are suppressed and discarded.
However, because we're doing this instantiation after the `ASTUnit` is fully loaded, clang would normally tear down many of the resources needed to do template instantiations, leading to various memory errors/crashes. We use `-fincremental-extensions` to suppress this teardown.
In the future, we hope to do these instantiations inline with the initial `ASTUnit` loading which would allow us to remove our dependency on `-fincremental-extensions`.
We are currently in the process of trying to identify what commit or set of commits introduced this regression.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVUtv4zYQ_jX0ZWBDpt8HH5xm3e6tgFOkPVLiyOIuRarDob3uIb-9GMlO4n10gQKJLFKc1zcfvzEpuWNA3KrFg1o8jkzmJtK2iqcxd-RChaMy2sv2GYGwwsD-AokNMVrgBqGjWGFKwBFydyRjEWImqCkGxmBlv_ImHGG6nMBv8YwnJKV_gTOCdamKJyS0YKA2jsQ1kos5AeGRM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