Home Dashboard Directory Help
Search

cl static assertion parsing error by PublicReport


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 686324
Opened: 8/31/2011 2:00:27 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

The following code does not compile with both Visual Studio 2008 and Visual Studio 2010.

#include <iostream>
#include <boost/static_assert.hpp>

template<int HamSize>
struct Spam
{
    static const int Ham = HamSize;
};

template<typename SomeSpam, int OtherHamSize>
struct Pizza
{
    typedef typename SomeSpam             Left;
    typedef typename Spam<OtherHamSize>    Right;

    static const bool test = Left::Ham < Right::Ham;

    BOOST_STATIC_ASSERT(((Right::Ham > Left::Ham)));
    /// Does not compile with MSVC
    BOOST_STATIC_ASSERT(((Left::Ham < Right::Ham)));
};


int main()
{
    std::cout << "Hello, World" << std::endl;
    Pizza<Spam<8>, 9> t1;
}

- The same problem exists with static_assert instead of BOOST_STATIC_ASSERT
- Only BOOST_STATIC_ASSERT(((Left::Ham < Right::Ham))); fails, the greater than comparison works.
- Asserting on either Left::Ham or Right::Ham works
Details
Sign in to post a comment.
Posted by Microsoft on 1/24/2012 at 11:58 AM
Hi:
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 8/31/2011 at 10:58 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 8/31/2011 at 2:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by UnitUniverse on 8/31/2011 at 11:35 PM
#include <iostream>
#include <boost/static_assert.hpp>

template<int HamSize>
struct Spam
{
    static const int Ham = HamSize;
};

template<typename SomeSpam, int OtherHamSize>
struct Pizza
{
    typedef typename SomeSpam             Left;
    typedef typename Spam<OtherHamSize>    Right;

    static const bool test = Left::Ham < Right::Ham;

    static_assert(((Right::Ham > Left::Ham)), "right");
    /// Does not compile with MSVC
    //static_assert(((Left::Ham < Right::Ham)). "wrong");
};

It will work unless you released the last line. In false status the 'wrong' should be reported in design instead of the useless C2059 errors :-(

int main()
{
    std::cout << "Hello, World" << std::endl;
    Pizza<Spam<8>, 9> t1;
}