Community
cancel
Showing results for 
Search instead for 
Did you mean: 
John_S_20
Beginner
60 Views

Friend declaration doesn't apply to partial specializations in icc v.13.0.089

If someone has access to some more official bug reporting mechanism, I'd appreciate if you filed a bug report about this: (using Intel C++ Composer XE 2013 [v.13.0.089] on Windows)

[cpp]

#include <type_traits>


template <typename T, int guid, typename Enable = void>
struct has_type_guid
    : std::false_type
{};


template <typename T, int guid>
struct has_type_guid< T, guid, typename std::enable_if<T::_type_guid == guid>::type>
    : std::true_type
{};


struct MyStruct
{
    template <typename T, int guid, typename Enable>
    friend struct has_type_guid;


private:
    enum { _type_guid = 42 };
};


int main()
{
    static_assert(has_type_guid<MyStruct, 42>::value, "");
    return 0;
}


// Test.cpp(30): error : static assertion failed with ""
// static_assert(has_type_guid<MyStruct, 42>::value, "");
// ^

[/cpp]

EDIT:

Although, I'm not so sure anymore that this is a bug, since GCC 4.7.1 doesn't compile the code either (complaining that "MyStruct::_type_guid is private"). Microsoft Visual C++ 11.0 compiles it just fine though.

0 Kudos
2 Replies
Judith_W_Intel
Employee
60 Views

Hi, This actually has to with our support for SFINAE (Substitution Failure Is Not An Error) in microsoft emulation mode. It turns out the Microsoft compiler does not do access checking in SFINAE contexts, and in addition, does not do access checking during the partial instantiation of a function template. In addition, access errors that occur during the partial instantiation of a function template are ignored in the Microsoft compiler. You'll notice that MSVC++ 2010 doesn't complain even if you remove the friend declaration. So we needed to emulate this behaviour in our Windows based compiler. We have implemented this and you should see the fix in the next 13.0 update. You'll note that the GNU compiler (and our Linux based compiler) will give an error. thank you for reporting it. Judy
Judith_W_Intel
Employee
60 Views

Oh by the way this is being tracked/fix in our internal bug database under the number DPD200178656.
Reply