Bug 24818 - tr1::reference_wrapper improperly calls nullary function objects
Summary: tr1::reference_wrapper improperly calls nullary function objects
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.1.0
: P3 minor
Target Milestone: 4.0.3
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-12 13:28 UTC by Doug Gregor
Modified: 2005-11-13 12:20 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-11-12 13:33:55


Attachments
Mainline (4.1.0) patch to test and fix this problem (649 bytes, patch)
2005-11-12 13:31 UTC, Doug Gregor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Gregor 2005-11-12 13:28:55 UTC
tr1::reference_wrapper<T>::operator()() should not dereference get() before calling the function object, because get() returns a reference (not a pointer).
Comment 1 Doug Gregor 2005-11-12 13:31:04 UTC
Created attachment 10225 [details]
Mainline (4.1.0) patch to test and fix this problem

The fix is trivial. The changes to the test case cause failures that are fixed by the patch to ref_wrap_iterate.h. All of the tr1/3_function_objects tests still pass on i686-pc-linux-gnu.

2005-11-12  Douglas Gregor  <doug.gregor@gmail.com>

	* include/tr1/ref_wrap_iterate.h
	(reference_wrapper::operator()()): Don't dereferene the result of
	get() before calling it; it's already a reference.
	* testsuite/tr1/3_function_objects/reference_wrapper/invoke.cc:
	Test nullary calls to reference_wrappers.
Comment 2 Paolo Carlini 2005-11-12 13:33:55 UTC
Thanks a lot. I will take care of applying the patch asap.
Comment 3 paolo@gcc.gnu.org 2005-11-13 12:14:19 UTC
Subject: Bug 24818

Author: paolo
Date: Sun Nov 13 12:14:15 2005
New Revision: 106862

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106862
Log:
2005-11-13  Jonathan Wakely  <redi@gcc.gnu.org>

	* include/tr1/boost_shared_ptr.h (get_deleter):
	Declare before shared_ptr.
	(shared_ptr<>): Declare get_deleter as friend.
	(shared_ptr<>:_M_get_deleter): Private.

2005-11-13  Douglas Gregor  <doug.gregor@gmail.com>

	PR libstdc++/24818
        * include/tr1/ref_wrap_iterate.h
        (reference_wrapper::operator()()): Don't dereferene the result of
        get() before calling it; it's already a reference.
        * testsuite/tr1/3_function_objects/reference_wrapper/invoke.cc:
        Test nullary calls to reference_wrappers.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/tr1/ref_wrap_iterate.h
    trunk/libstdc++-v3/testsuite/tr1/3_function_objects/reference_wrapper/invoke.cc

Comment 4 paolo@gcc.gnu.org 2005-11-13 12:14:57 UTC
Subject: Bug 24818

Author: paolo
Date: Sun Nov 13 12:14:51 2005
New Revision: 106863

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106863
Log:
2005-11-13  Jonathan Wakely  <redi@gcc.gnu.org>

	* include/tr1/boost_shared_ptr.h (get_deleter):
	Declare before shared_ptr.
	(shared_ptr<>): Declare get_deleter as friend.
	(shared_ptr<>:_M_get_deleter): Private.

2005-11-13  Douglas Gregor  <doug.gregor@gmail.com>

	PR libstdc++/24818
        * include/tr1/ref_wrap_iterate.h
        (reference_wrapper::operator()()): Don't dereferene the result of
        get() before calling it; it's already a reference.
        * testsuite/tr1/3_function_objects/reference_wrapper/invoke.cc:
        Test nullary calls to reference_wrappers.

Modified:
    trunk/libstdc++-v3/include/tr1/boost_shared_ptr.h

Comment 5 paolo@gcc.gnu.org 2005-11-13 12:19:09 UTC
Subject: Bug 24818

Author: paolo
Date: Sun Nov 13 12:19:01 2005
New Revision: 106864

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106864
Log:
2005-11-13  Douglas Gregor  <doug.gregor@gmail.com>

	PR libstdc++/24818
        * include/tr1/ref_wrap_iterate.h
        (reference_wrapper::operator()()): Don't dereferene the result of
        get() before calling it; it's already a reference.
        * testsuite/tr1/3_function_objects/reference_wrapper/invoke.cc:
        Test nullary calls to reference_wrappers.

2005-11-13  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/24799
	* include/tr1/functional (hash): Inherit from std::unary_function.
	* testsuite/tr1/6_containers/unordered/hash/24799.cc: New.

	PR libstdc++/24805
	* include/tr1/boost_shared_ptr.h (swap(shared_ptr<>&, shared_ptr<>&),
	swap(weak_ptr<>&, weak_ptr<>&)): Move inside namespace tr1.
	* testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/
	24805.cc: New.

	PR libstdc++/24809
	* include/tr1/type_traits (__is_polymorhpic_helper): Adjust destructor.
	* testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/
	24809.cc: New.

Added:
    branches/gcc-4_0-branch/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc
    branches/gcc-4_0-branch/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/24809.cc
    branches/gcc-4_0-branch/libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/
    branches/gcc-4_0-branch/libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/24799.cc
Modified:
    branches/gcc-4_0-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_0-branch/libstdc++-v3/include/tr1/boost_shared_ptr.h
    branches/gcc-4_0-branch/libstdc++-v3/include/tr1/functional
    branches/gcc-4_0-branch/libstdc++-v3/include/tr1/ref_wrap_iterate.h
    branches/gcc-4_0-branch/libstdc++-v3/include/tr1/type_traits
    branches/gcc-4_0-branch/libstdc++-v3/testsuite/tr1/3_function_objects/reference_wrapper/invoke.cc

Comment 6 Paolo Carlini 2005-11-13 12:20:39 UTC
Fixed for 4.0.3.