<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 - -Wdeprecated-declarations warns about "usage" with uniform initialization"
href="https://bugs.llvm.org/show_bug.cgi?id=45170">45170</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-Wdeprecated-declarations warns about "usage" with uniform initialization
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>bugzilla.llvm@me.benboeckel.net
</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>This code:
```
struct S {
int a;
__attribute__((deprecated)) int b;
int c;
};
S f() {
return S{1, 2, 3};
}
```
triggers this warning with Fedora's clang-9.0.1:
```
% clang++ -c deprecated_member.cxx
-
deprecated_member.cxx:8:17: warning: 'b' is deprecated
[-Wdeprecated-declarations]
return S{1, 2, 3};
^
deprecated_member.cxx:3:20: note: 'b' has been explicitly marked deprecated
here
__attribute__((deprecated)) int b;
^
deprecated_member.cxx:1:8: warning: 'b' is deprecated
[-Wdeprecated-declarations]
struct S {
^
deprecated_member.cxx:8:12: note: in implicit move constructor for 'S' first
required here
return S{1, 2, 3};
^
deprecated_member.cxx:3:20: note: 'b' has been explicitly marked deprecated
here
__attribute__((deprecated)) int b;
^
2 warnings generated.
```
This is a false positive because, due to the lack of designated initializers,
in order to initialize `c` here, I *must* initialize `b`. The warning should
only show up on the explicit use of `b`, not on its presence in the
initialization list. This also happens with `S s = {1, 2, 3};`.
Real world code is hitting this with the PyObject's deprecated `tp_print`
member in Python 3.9.
May be related to <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - __attribute__((deprecated)) doesn't appear for implicit construction of rvalues [-Wdeprecated-declarations]"
href="show_bug.cgi?id=25472">Bug #25472</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>