Bug 55866 - [4.8 Regression] #include <auto_ptr.h> in C++11 mode
Summary: [4.8 Regression] #include <auto_ptr.h> in C++11 mode
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-03 16:37 UTC by Jakub Jelinek
Modified: 2013-01-03 17:10 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2013-01-03 16:37:46 UTC
echo '#include <auto_ptr.h>' | g++ -std=gnu++0x -S -o /tmp/a.s -xc++ -
worked in 4.7, but doesn't work any longer in 4.8.  Apparently the snapper
package does this in one of the translation units (no idea why).
Is that an error in the package and it isn't supposed to include that header, or is that something to fix on the libstdc++ side?
The problem started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190109
where auto_ptr.h relies on a couple of headers it doesn't include itself (so _Lock_policy, __shared_count etc. aren't defined).
Comment 1 Jonathan Wakely 2013-01-03 16:55:04 UTC
It's an error in the package and only worked "by accident" because $PREFIX/include/c++/4.x.y/backward is in the include path, to allow <strstream> to be found.

The only supported way to use std::auto_ptr is #include <memory>
Comment 2 Jonathan Wakely 2013-01-03 17:01:12 UTC
The header even says so, and has done so for years:

/** @file backward/auto_ptr.h
 *  This is an internal header file, included by other library headers.
 *  Do not attempt to use it directly. @headername{memory}
 */


The change was an important one that allows us to use unique_ptr and shared_ptr internally in the library (e.g. in <future>) without depending on the whole of <memory> and without pulling in the deprecated auto_ptr definition, as discussed in the thread beginning at http://gcc.gnu.org/ml/libstdc++/2012-06/msg00078.html

I don't want to revert it, and it would contradict how the entire library is structured to make <backward/auto_ptr.h> pull in all its needed headers. If you #include <memory> it works perfectly, anything else is unsupported.
Comment 3 Jakub Jelinek 2013-01-03 17:10:07 UTC
I have no problem with that, just noticed this during mass rebuild with gcc 4.8 and wanted to double check where the bug is.