<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 - bogus -Wmissing-braces for CTAD deduced aggregate with inherited base"
href="https://bugs.llvm.org/show_bug.cgi?id=46776">46776</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>bogus -Wmissing-braces for CTAD deduced aggregate with inherited base
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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++17
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wjwray@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>Combination of aggregate CTAD and inheritance makes -Wmissing-braces wrong.
For example, take a tuple class with the usual CTAD:
<a href="https://wandbox.org/permlink/USZGcupYvTtP8D6D">https://wandbox.org/permlink/USZGcupYvTtP8D6D</a>
template <typename...> struct tuple;
template <typename... T> tuple(T...) -> tuple<T...>;
Implement it as an aggregate, by explicit specializations:
template <> struct tuple<> {};
template <typename A> struct tuple<A> {A a;};
template <typename A, typename B> struct tuple<A,B> {A a; B b;};
... & etc.
Now, 'tie' is usually implemented as a helper 'make' function tie(...)
Instead, implement tie as a class inheriting from tuple, with CTAD
template <typename... T> struct tie : tuple<T...> {};
template <typename... T> tie(T&...) -> tie<T&...>;
along with an extra tuple CTAD converting from tie to tuple
template <typename... T> tuple(tie<T...>) -> tuple<T...>;
Now, usage of tie looks like this:
bool up = true;
tuple t = tie{up};
warning: suggest braces around initialization of subobject [-Wmissing-braces]
tuple t = tie{up};
^~
{ }
1 warning generated.
However, this warning is incorrect here -
adding the suggested braces breaks the CTAD deduction.</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>