Opened 10 years ago

Closed 9 years ago

#7317 closed Bugs (fixed)

[type_traits] remove_const not working on vc11

Reported by: Eric Niebler Owned by: John Maddock
Milestone: To Be Determined Component: type_traits
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

One of proto's tests is currently failing on vc11 with the following error:

external_transforms.cpp
C:\local\Regression\boost\boost/type_traits/remove_const.hpp(52) : error C2039: 'unqualified_type' : is not a member of 'boost::detail::cv_traits_imp<T>'
        with
        [
            T=void (__cdecl *const *)(void)
        ]
        C:\local\Regression\boost\boost/type_traits/remove_const.hpp(73) : see reference to class template instantiation 'boost::detail::remove_const_impl<T>' being compiled
        with
        [
            T=void (__cdecl *const )(void)
        ]

John, can you have a look? The proto test in question is external_transforms if you need a repro.

Attachments (1)

cv_traits_imp.patch (6.3 KB ) - added by Eric Niebler 10 years ago.
latest version of the patch

Download all attachments as: .zip

Change History (8)

comment:1 by John Maddock, 10 years ago

Eric I'm not sure what I can do here: I don't have that compiler (and won't until they decide to release the desktop express edition), but more particularly it looks like a clear compiler bug. That code has been unchanged since the beginning of time and always worked well too. Do you have VC11? If so you could try adding a:

template <typename T> struct cv_traits_imp<T*const*> {

BOOST_STATIC_CONSTANT(bool, is_const = true); BOOST_STATIC_CONSTANT(bool, is_volatile = false); typedef T* unqualified_type;

};

partial specialization to cv_traits_imp.hpp and see if that helps?

comment:2 by Eric Niebler, 10 years ago

I don't have a copy of vc11 either. Could very well be a regression in the compiler. I suppose you could post a msg to the devel list and see if anybody is willing to try the fix for you. And once the compiler is publicly available, we can come up with a minimal repro and file a compiler bug. I'd think they'd want to fix this one if it's a regression that affects boost.

comment:3 by Eric Niebler, 10 years ago

I downloaded the free version of msvc-11 and isolated the bug. It does appear to be a regression in the msvc compiler. I've reported it here:

https://connect.microsoft.com/VisualStudio/feedback/details/764446/regression-cannot-partially-specialize-class-on-ptr-to-funtion-when-function-type-is-deduced#details

I'll see if I can come up with a work-around. It'd be nice to get this fixed for 1.52.

comment:4 by Eric Niebler, 10 years ago

I haven't added a test for this because it looks like you have a TT testing system that I haven't grokked. But here is a very simple test case that should expose the problem.

#include <boost/type_traits/remove_const.hpp>

struct S
{
    template<typename T>
    typename boost::remove_const<T>::type *operator=(T const &t) const { return 0; }
};

void bar() {}

int main()
{
    S s;
    s = bar;
}

With the patch, this compiles. Without it, it doesn't.

comment:5 by Eric Niebler, 10 years ago

Oh wait. This introduces a couple of regressions I need to investigate. I'll get back to this.

by Eric Niebler, 10 years ago

Attachment: cv_traits_imp.patch added

latest version of the patch

comment:6 by Eric Niebler, 10 years ago

OK, the attached patch seems to do the trick and doesn't introduce regressions as far as I can tell. I think that a better fix would be to simply defer to std::remove_const and friends. But then, that could be done for all traits that have compatible C++11 implementations. That seemed like a bigger change. I'll leave that up to you.

comment:7 by John Maddock, 9 years ago

Resolution: fixed
Status: newclosed

A little late in the day, but patches tested and applied to develop.

Note: See TracTickets for help on using tickets.