Opened 12 years ago

Closed 12 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;

Change History (2)

comment:1 by Mathias Gaunard, 12 years ago

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

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.

Note: See TracTickets for help on using tickets.