http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55557

             Bug #: 55557
           Summary: g++ 4.7 does not issue a warning on the first auto_ptr
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: pashev.i...@gmail.com


Here is a C++ source code:

# cat -n test.cpp
 1  #include <memory>
 2  using namespace std;
 3   
 4  int main(int argc, char **argv)
 5  {
 6      auto_ptr<int> x;
 7      auto_ptr<int> y;
 8      auto_ptr<int> z;
 9   
10      return 0;
11  }

Command line to compile it with C++11 standard:
g++-4.7 -std=gnu++11 -Wall -Wextra -Wdeprecated-declarations  -pedantic
test.cpp 

Here is the g++ output:
test.cpp: In function ‘int main(int, char**)’:
test.cpp:7:19: warning: ‘auto_ptr’ is deprecated (declared at
/usr/include/c++/4.7/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
test.cpp:8:19: warning: ‘auto_ptr’ is deprecated (declared at
/usr/include/c++/4.7/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
test.cpp: At global scope:
test.cpp:4:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
test.cpp:4:5: warning: unused parameter ‘argv’ [-Wunused-parameter]

A warning about auto_ptr being deprecated has been issued only for y and z. I
expect a warning for x too.

Moreover, if I leave only one auto_ptr (say, x) I will see no deprecation
warning at all.

It is expected to see warning on every auto_ptr instantiation.

Reply via email to