I found this question/answer which describes the use of [[deprecated]] as a C++14 feature to instruct the compiler to warn about the use of deprecated functions.
I tried using this in a simple function within a project - the warning was issued 3 times. I initially thought this might be multiple template instantiations, so I tested a simple program.
[[deprecated]] void doNothing() {}
int main(){
doNothing();
}
g++ -std=c++14 deprecatedTest.cpp outputs
deprecatedTest.cpp: In function 'int main()':
deprecatedTest.cpp:4:5: warning: 'void doNothing()' is deprecated [-Wdeprecated-declarations]
doNothing();
^
deprecatedTest.cpp:1:21: note: declared here
[[deprecated]] void doNothing() {}
^
deprecatedTest.cpp:4:5: warning: 'void doNothing()' is deprecated [-Wdeprecated-declarations]
doNothing();
^
deprecatedTest.cpp:1:21: note: declared here
[[deprecated]] void doNothing() {}
^
deprecatedTest.cpp:4:15: warning: 'void doNothing()' is deprecated [-Wdeprecated-declarations]
doNothing();
^
deprecatedTest.cpp:1:21: note: declared here
[[deprecated]] void doNothing() {}
Is the warning supposed to be printed 3 times? (To get more attention?)
This seems a strange behaviour, but I can't imagine a simpler test.
This is an obvious Quality of Implementation issue, and not likely to be intentional.
Just raise it on GCC Bugzilla if it's not already there.
OP has raised this on Bugzilla, as suggested. ☺
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With