Opened 12 years ago

Closed 12 years ago

#4174 closed Patches (fixed)

Patch to fix auto_ptr usage errors in ptr_container tests

Reported by: Douglas Gregor Owned by: Thorsten Ottosen
Milestone: Boost 1.43.0 Component: ptr_container
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

At several places in the ptr_container tests, we have the following pattern:

void f(const std::auto_ptr<int> &); void g() {

f(std::auto_ptr<int>(new int(5)));

}

This is code is ill-formed in C++98/03, because the compiler is required to check there there exits a copy constructor that would be able to make a copy of the auto_ptr before binding it to a reference, even if that copy won't actually be made. Not all compilers diagnose this error, but Clang and EDG in strict mode do diagnose the problem.

The attached patch fixes the issue.

Attachments (1)

ptr_container_const_ref_fixes.patch (2.8 KB ) - added by Douglas Gregor 12 years ago.
Patch fixing the problem

Download all attachments as: .zip

Change History (3)

by Douglas Gregor, 12 years ago

Patch fixing the problem

comment:1 by Douglas Gregor, 12 years ago

Component: Noneptr_container
Owner: set to Thorsten Ottosen

comment:2 by Douglas Gregor, 12 years ago

Resolution: fixed
Status: newclosed

(In [61718]) At several places in the ptr_container tests, we have the following pattern:

void f(const std::auto_ptr<int> &); void g() {

f(std::auto_ptr<int>(new int(5)));

}

This is code is ill-formed in C++98/03, because the compiler is required to check there there exits a copy constructor that would be able to make a copy of the auto_ptr before binding it to a reference, even if that copy won't actually be made. Not all compilers diagnose this error, but Clang and EDG in strict mode do diagnose the problem.

Fixes #4174.

Note: See TracTickets for help on using tickets.