Opened 6 years ago

Closed 6 years ago

#5271 closed Bugs (fixed)

is_convertible with 16-byte aligned types causes errors on MSVC

Reported by: mgaunard Owned by: johnmaddock
Milestone: To Be Determined Component: type_traits
Version: Boost Development Trunk Severity: Problem
Keywords: is_convertible msvc alignment Cc:


This appears to be caused by passing those types by value to functions, as is done by "...". MSVC doesn't allow types with alignment higher than that of the stack to be passed by value to functions.

The fix would involve forcing everything to be references somehow.


#include <boost/type_traits/is_convertible.hpp>

struct A
    __declspec(align(16)) int value;

struct B

typedef boost::is_convertible<A, B>::type C;

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by mgaunard

It doesn't really seem fixable within the field of portable C++03, so I see three solutions:

  • use std::is_convertible or std::tr1::is_convertible if either is available
  • use the __is_convertible_to built-in on MSVC (available since 7.1)
  • use SFINAE extended to expressions, if available, to implement this trait without passing by value to a function

Solution number 2 seems to be the easiest one for a quick fix, and the one most MSVC versions will be able to benefit from.

comment:2 Changed 6 years ago by johnmaddock

  • Resolution set to fixed
  • Status changed from new to closed

(In [69822]) Change is_convertible to use C++0x behaviour where possible. Change is_converible to use MSVC is_convertible intrinsic. Fixes #5271. Fixes #4530.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain johnmaddock.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.