User account creation filtered due to spam.

Bug 48631 - [C++0x] default_delete<T[]> accepts pointer conversions in function call operator
Summary: [C++0x] default_delete<T[]> accepts pointer conversions in function call oper...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-15 19:55 UTC by Daniel Krügler
Modified: 2011-04-16 02:09 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-04-16 01:19:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-04-15 19:55:52 UTC
The following program using 4.7.0 20110409 (experimental) should be rejected, but is accepted:

//------------
#include <memory>

struct B {};
struct D : B {};

int main() {
  D d;
  std::default_delete<B[]> db;
  typedef decltype(db(&d)) type;
}
//------------

Reason for this deviation of the spec is the missing deleted function call operator as described in [unique.ptr.dltr.dflt1]:

template <class T> struct default_delete<T[]> {
  constexpr default_delete() noexcept = default;
  void operator()(T*) const;
  template <class U> void operator()(U*) const = delete;
};
Comment 1 Paolo Carlini 2011-04-16 01:19:45 UTC
I'm handling this one too.
Comment 2 paolo@gcc.gnu.org 2011-04-16 02:02:35 UTC
Author: paolo
Date: Sat Apr 16 02:02:29 2011
New Revision: 172534

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172534
Log:
2011-04-15  Daniel Krugler  <daniel.kruegler@googlemail.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/48631
	* include/bits/unique_ptr.h (default_delete<_Tp[]>): Add deleted
	function call operator.
	* testsuite/20_util/default_delete/48631_neg.cc: New.
	* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-error
	line numbers.

Added:
    trunk/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/unique_ptr.h
    trunk/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc
Comment 3 paolo@gcc.gnu.org 2011-04-16 02:05:01 UTC
Author: paolo
Date: Sat Apr 16 02:04:56 2011
New Revision: 172535

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172535
Log:
2011-04-15  Daniel Krugler  <daniel.kruegler@googlemail.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/48631
	* include/bits/unique_ptr.h (default_delete<_Tp[]>): Add deleted
	function call operator.
	* testsuite/20_util/default_delete/48631_neg.cc: New.
	* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-error
	line numbers.

Added:
    branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
Modified:
    branches/gcc-4_6-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_6-branch/libstdc++-v3/include/bits/unique_ptr.h
    branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc
Comment 4 Paolo Carlini 2011-04-16 02:05:43 UTC
Done. Fixed mainline and 4_6-branch.
Comment 5 Paolo Carlini 2011-04-16 02:09:46 UTC
Jason, in case the issue is not known and your are interested: after the library fix we reject the snippet but we give the error message twice.