Modify

Opened 7 years ago

Closed 7 years ago

#5271 closed Bugs (fixed)

is_convertible with 16-byte aligned types causes errors on MSVC

Reported by: Mathias Gaunard Owned by: John Maddock
Milestone: To Be Determined Component: type_traits
Version: Boost Development Trunk Severity: Problem
Keywords: is_convertible msvc alignment Cc:

Description

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.

Testcase:

#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 7 years ago by Mathias Gaunard

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 7 years ago by John Maddock

Resolution: fixed
Status: newclosed

(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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.