Valgrind false positive in make_shared

Date: Thu, 18 Nov 2010 19:51:55 +0200 From: "Peter Dimov"
Dave Steffen wrote:
I got this bad behavior with GCC 4.4.4. It goes away with GCC 4.2.4.
What is the definition of std::forward in GCC 4.4.4? What happens if you
change boost::detail::sp_forward in make_shared.hpp:150: ::new( pv ) T( boost::detail::sp_forward<Arg1>( arg1 ),
boost::detail::sp_forward<Args>( args )... );
to std::forward, do you get a compile warning on this line and does Valgrind still warn?
Hi Coming back to this issue after a week or two... trying the above made no difference: no compiler warnings, and no change in Valgrind's error messages. Any thoughts? Thanks! -- Dave Steffen, Ph.D. - Software Engineer Numerica Corporation http://www.numerica.us 4850 Hahns Peak Drive, Suite 200 Loveland, Colorado 80538 main (970) 461-2000 x 227 direct (970) 612-2327 Email: dave.steffen@numerica.us fax (970) 461-2004 This message and any attachments are intended only for the individual or entity to which the message is addressed. This is a private message and may contain privileged information. If you are neither the intended recipient nor the agent responsible for delivering the message to the intended recipient, you are hereby notified that any review, retransmission, dissemination, or taking of any action in reliance upon, the information in this communication is strictly prohibited, and may be unlawful. If you feel you have received this communication in error, please notify me immediately by returning this email to me and deleting it from your computer.

Dave Steffen wrote:
Hi
Coming back to this issue after a week or two... trying the above
[changing to std::forward]
made no difference: no compiler warnings, and no change in Valgrind's error messages.
Looks like a g++ bug then. You should try reproducing it in a self-contained example and report it to the GCC Bugzilla. I'm not sure what we can do on our end to avoid it. (I'll switch to std::forward in any case, since this seems a good idea in general, but it won't help in this specific case.)

On Tuesday, November 30, 2010 03:40:14 am Peter Dimov wrote:
Dave Steffen wrote:
Hi
Coming back to this issue after a week or two... trying the above
[changing to std::forward]
made no difference: no compiler warnings, and no change in Valgrind's error messages.
Looks like a g++ bug then. You should try reproducing it in a self-contained example and report it to the GCC Bugzilla. I'm not sure what we can do on our end to avoid it. (I'll switch to std::forward in any case, since this seems a good idea in general, but it won't help in this specific case.)
I reported this as GCC bug 46732. You can see the whole discussion at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46732 but the short version is: There was a defect in the language, core issue 664 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#664 GCC 4.4 predates that issue being resolved, so the only real workaround is to avoid using -std=c++0x with GCC 4.4 (thanks to Jonathan Wakely for getting to this so quickly) -- Dave Steffen, Ph.D. - Software Engineer Numerica Corporation http://www.numerica.us 4850 Hahns Peak Drive, Suite 200 Loveland, Colorado 80538 main (970) 461-2000 x 227 direct (970) 612-2327 Email: dave.steffen@numerica.us fax (970) 461-2004 This message and any attachments are intended only for the individual or entity to which the message is addressed. This is a private message and may contain privileged information. If you are neither the intended recipient nor the agent responsible for delivering the message to the intended recipient, you are hereby notified that any review, retransmission, dissemination, or taking of any action in reliance upon, the information in this communication is strictly prohibited, and may be unlawful. If you feel you have received this communication in error, please notify me immediately by returning this email to me and deleting it from your computer.

On Tuesday, November 30, 2010 01:46:39 pm Dave Steffen wrote:
On Tuesday, November 30, 2010 03:40:14 am Peter Dimov wrote:
Dave Steffen wrote:
Hi
Coming back to this issue after a week or two... trying the above
[changing to std::forward]
made no difference: no compiler warnings, and no change in Valgrind's error messages.
Looks like a g++ bug then. You should try reproducing it in a self-contained example and report it to the GCC Bugzilla. I'm not sure what we can do on our end to avoid it. (I'll switch to std::forward in any case, since this seems a good idea in general, but it won't help in this specific case.)
I reported this as GCC bug 46732. You can see the whole discussion at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46732
but the short version is:
There was a defect in the language, core issue 664 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#664
GCC 4.4 predates that issue being resolved, so the only real workaround is to avoid using -std=c++0x with GCC 4.4
(thanks to Jonathan Wakely for getting to this so quickly)
... and as a last note, GCC 4.5.1 compiles the code cleanly, and Valgrind finds nothing to object to. Thanks! -- Dave Steffen, Ph.D. - Software Engineer Numerica Corporation http://www.numerica.us 4850 Hahns Peak Drive, Suite 200 Loveland, Colorado 80538 main (970) 461-2000 x 227 direct (970) 612-2327 Email: dave.steffen@numerica.us fax (970) 461-2004 This message and any attachments are intended only for the individual or entity to which the message is addressed. This is a private message and may contain privileged information. If you are neither the intended recipient nor the agent responsible for delivering the message to the intended recipient, you are hereby notified that any review, retransmission, dissemination, or taking of any action in reliance upon, the information in this communication is strictly prohibited, and may be unlawful. If you feel you have received this communication in error, please notify me immediately by returning this email to me and deleting it from your computer.

On Tuesday, November 30, 2010 03:41:29 pm Dave Steffen wrote:
On Tuesday, November 30, 2010 01:46:39 pm Dave Steffen wrote:
On Tuesday, November 30, 2010 03:40:14 am Peter Dimov wrote:
Dave Steffen wrote:
Hi
Coming back to this issue after a week or two... trying the above
[changing to std::forward]
made no difference: no compiler warnings, and no change in Valgrind's error messages.
Looks like a g++ bug then. You should try reproducing it in a self-contained example and report it to the GCC Bugzilla. I'm not sure what we can do on our end to avoid it. (I'll switch to std::forward in any case, since this seems a good idea in general, but it won't help in this specific case.)
I reported this as GCC bug 46732. You can see the whole discussion at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46732
but the short version is: There was a defect in the language, core issue 664 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#664
GCC 4.4 predates that issue being resolved, so the only real workaround
is to
avoid using -std=c++0x with GCC 4.4
(thanks to Jonathan Wakely for getting to this so quickly)
Jonathan Wakely has proposed a fix; since I'm guessing nobody out there is watching the bug report, I thought I'd pass this along. ----------------------------------------------------------------------
GCC 4.4 predates that issue being resolved, so the only real workaround is to avoid using -std=c++0x with GCC 4.4
Or do something like I did for std::move in my initial implementation of
std::future, which returned scalars by value rather than by rvalue-reference:
// workaround for CWG issue 664 and c++/34022
template
participants (2)
-
Dave Steffen
-
Peter Dimov