[llvm-bugs] [Bug 45170] New: -Wdeprecated-declarations warns about "usage" with uniform initialization

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 10 13:02:25 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45170

            Bug ID: 45170
           Summary: -Wdeprecated-declarations warns about "usage" with
                    uniform initialization
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bugzilla.llvm at me.benboeckel.net
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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 Bug #25472?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200310/00bb9805/attachment.html>


More information about the llvm-bugs mailing list