I noticed strange behaviour. It can be narrowed to the following example:
#include <memory>
int main() {
std::auto_ptr<int> p1(new int);
#ifdef AUTODEP
std::auto_ptr<int> p2(new int);
#endif
}
and compilation
cpptests$ g++ -Wall -std=c++1y dep.cc
cpptests$ g++ -DAUTODEP -Wall -std=c++1y dep.cc
dep.cc: In function ‘int main()’:
dep.cc:7:24: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
std::auto_ptr p2(new int);
Is any reason why there is no warning when auto_ptr is used just once ?
tested on
gcc (Debian 4.9.2-16) 4.9.2 and gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
I have also checked that code is not optimized out.
This a known bug of GCC 33911, with status NEW
.