Bug 85353 - deprecation warning issued on data member with initializer
Summary: deprecation warning issued on data member with initializer
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2018-04-11 16:41 UTC by Ryan R Haining
Modified: 2018-04-11 19:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-04-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan R Haining 2018-04-11 16:41:58 UTC
The following code issues deprecation warnings. "warning: 'Cls::x' is deprecated "
struct Cls {
  [[deprecated]] int x = 0; // removing = 0 silences warning
};

int main() {
  Cls c;
}

The warning is only issued when the `= 0` is present. This code shouldn't be warning at all. Live at wandbox: https://wandbox.org/permlink/sqR7DvAlMfllCES0
Comment 1 Martin Sebor 2018-04-11 19:57:14 UTC
Confirmed with the extended test case below and __attribute__ ((deprecated)).  It doesn't appear to be a regression.

$ cat pr85353.C && gcc -S -Wall pr85353.C
struct A {
  __attribute__ ((deprecated)) int x = 0;
} a;

struct B {
  __attribute__ ((deprecated)) int y;
} b;

struct C {
  __attribute__ ((deprecated)) int x = 0;
  __attribute__ ((deprecated)) int y;
} c;
pr85353.C: In constructor ‘constexpr A::A()’:
pr85353.C:1:8: warning: ‘A::x’ is deprecated [-Wdeprecated-declarations]
 struct A {
        ^
pr85353.C:2:40: note: declared here
   __attribute__ ((deprecated)) int x = 0;
                                        ^
pr85353.C:1:8: warning: ‘A::x’ is deprecated [-Wdeprecated-declarations]
 struct A {
        ^
pr85353.C:2:40: note: declared here
   __attribute__ ((deprecated)) int x = 0;
                                        ^
pr85353.C: At global scope:
pr85353.C:3:3: note: synthesized method ‘constexpr A::A()’ first required here
 } a;
   ^
pr85353.C: In constructor ‘C::C()’:
pr85353.C:9:8: warning: ‘C::x’ is deprecated [-Wdeprecated-declarations]
 struct C {
        ^
pr85353.C:10:40: note: declared here
   __attribute__ ((deprecated)) int x = 0;
                                        ^
pr85353.C:9:8: warning: ‘C::x’ is deprecated [-Wdeprecated-declarations]
 struct C {
        ^
pr85353.C:10:40: note: declared here
   __attribute__ ((deprecated)) int x = 0;
                                        ^
pr85353.C:9:8: warning: ‘C::y’ is deprecated [-Wdeprecated-declarations]
 struct C {
        ^
pr85353.C:11:36: note: declared here
   __attribute__ ((deprecated)) int y;
                                    ^
pr85353.C:9:8: warning: ‘C::y’ is deprecated [-Wdeprecated-declarations]
 struct C {
        ^
pr85353.C:11:36: note: declared here
   __attribute__ ((deprecated)) int y;
                                    ^
pr85353.C: At global scope:
pr85353.C:12:3: note: synthesized method ‘C::C()’ first required here
 } c;
   ^