Opened 12 years ago

Closed 9 years ago

#4759 closed Bugs (invalid)

shared_ptr to bool cast with Intel C++ Composer XE 2011

Reported by: abrarov@… Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.49.0 Severity: Problem
Keywords: shared_ptr Intel bool cast Cc:

Description

shared_ptr-to-bool cast sometimes doesn't work on Intel C++ Compiler 11.1.

Suggested patch:

--- boost/smart_ptr/detail/operator_bool.hpp	Пн мар  2 10:45:22 2009
+++ boost/smart_ptr/detail/operator_bool.hpp	Чт сен  2 23:30:11 2010
@@ -6,7 +6,7 @@
 //  See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt
 
-#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
+#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) || defined (BOOST_INTEL)
 
     operator bool () const
     {

As test asio-samples project may be used. Watch at svn repository for the echo_server project: /src/ma/echo/server/session_manager.cpp:151. The "while" cycle doesn't work right (cycle works when shared ptr "active_session" points to nothing) without the suggested patch.

Attachments (3)

shared_ptr_operator_bool.patch (511 bytes ) - added by abrarov@… 12 years ago.
Suggested patch
intel_rvalue_ref_on.patch (424 bytes ) - added by abrarov@… 12 years ago.
Turn on rvalue referense support in Intel C++ Compiler 12
cpp_test.zip (4.1 KB ) - added by abrarov@… 11 years ago.
Problem showing test

Download all attachments as: .zip

Change History (13)

by abrarov@…, 12 years ago

Suggested patch

comment:1 by Peter Dimov, 12 years ago

Can you please attach a simple test case?

in reply to:  1 comment:2 by abrarov@…, 12 years ago

Replying to pdimov:

Can you please attach a simple test case?

I tried to provide a simple test case but it's not so simple (simple tests passes well).
Even in echo_server at some places Intel C++ Compiler works well (but failes in many places too).
The echo_server project is rather simple - it uses only Boost C++ Libraries and "standard" MS Windows headers. So it is rather simple to build it (from MS Visual Studio with integrated Intel C++ Compiler - use /build/intel11/asio-samples.sln).
Make test without patch and within it - and You'll see the difference.

comment:3 by abrarov@…, 12 years ago

It seems (working with Boost 1.46 with

#undef BOOST_NO_RVALUE_REFERENCES

added to boost/config/compiler/intel.hpp) that compiler option (added from Commind Line memo in project settings) /vmg is the source of problem.

I will update asio-samples project in a week to provide public access to Intel-Compiler-12-based projects.

by abrarov@…, 12 years ago

Attachment: intel_rvalue_ref_on.patch added

Turn on rvalue referense support in Intel C++ Compiler 12

in reply to:  3 comment:4 by abrarov@…, 12 years ago

Replying to abrarov@…:

It seems (working with Boost 1.46 with

#undef BOOST_NO_RVALUE_REFERENCES

added to boost/config/compiler/intel.hpp) that compiler option (added from Commind Line memo in project settings) /vmg is the source of problem.

I will update asio-samples project in a week to provide public access to Intel-Compiler-12-based projects.

Done. Project "echo_server" works fine with ICC 12.x and suggested patch and crashes because of shared_ptr-to-bool cast (src/ma/echo/server/session_manager.cpp: line 316) without patch.

by abrarov@…, 11 years ago

Attachment: cpp_test.zip added

Problem showing test

comment:5 by abrarov@…, 11 years ago

Test environment:

  1. Windows 7 Ultimate x86 Russian.
  2. MS Visual Studio 2010 SP1.
  3. Intel C++ Composer XE 2011 update 7.

See cpp_test.zip attachment for test showing problem in debug mode only. Note /vmg compiler option (not needed for MSVC 10.0, but required for Intel C++ Composer).

comment:6 by abrarov@…, 11 years ago

Test environment:

  1. Boost C++ Libraries 1.49.0

comment:7 by abrarov@…, 11 years ago

Summary: shared_ptr to bool cast with Intel C++ Compiler 11.1shared_ptr to bool cast with Intel C++ Composer XE 2011
Version: Boost 1.44.0Boost 1.49.0

comment:8 by Ross MacGregor <rossmpublic.gmail.com>, 10 years ago

Related bug #8152.

I am seeing the same issue with MSVC-9 and MSVC-10 compilers. The shared_ptr to bool conversion is causing write access violations when using the /vmg option. This looks like a compiler bug to me, as I reproduced it with the standard safe bool idiom implementation on a simple class.

in reply to:  8 comment:9 by Ross MacGregor <rossmpublic.gmail.com>, 10 years ago

My problem with the MSVC compilers turned out to be a binary incompatibility issue. I was using the pointers_to_members pragma but I did not apply it carefully enough (which looks rather difficult). I ended up with multiple member references using different internal representations. I violated the one definition rule.

This also may be the cause of this problem too. Maybe the /vmg option is not being consistently applied for the same smart pointer types?

comment:10 by Peter Dimov, 9 years ago

Resolution: invalid
Status: newclosed

Closing as too old and possibly no longer relevant.

Note: See TracTickets for help on using tickets.