Community
cancel
Showing results for 
Search instead for 
Did you mean: 
eldiener
New Contributor I
158 Views

C++11 SFINAE for expressions fails with Intel 18.0 and 19.0 on Windows

C++11 SFINAE for expressions fails with Intel C++ 18.0 and Intel C++ 19.0 even though it succeds with vc++14.1 and vc++14.2. The code:

template<class>
struct ignore {
    typedef void type;
};

template<class T>
T& object();

template<class T, class E = void>
struct trait {
    static const int value = 0;
};

template<class T>
struct trait<T, typename ignore<decltype(&object<T>())>::type> { };

template<class T>
struct result {
    static const int value = T::value;
};

class type {
    void operator&() const { }
};

int test()
{
    return result<trait<type> >::value;
}

int main() 
	{
    return test();
    }

The error:

test_cxx11_sfinae_expression.cpp
test_cxx11_sfinae_expression.cpp(19): error: class "trait<type, void>" has no member "value"
      static const int value = T::value;
                                  ^
          detected during instantiation of class "result<T> [with T=trait<type, void>]" at line 28

The code also fails with earlier versions of Intel C++ on Windows but this is expected since it also fails with vc++14.0 on down. Since Intel C++ is compilng in C++14 mode by default, in order to emulate vc++ 14.1 on up, the code should compile correctly.

0 Kudos
6 Replies
Viet_H_Intel
Moderator
158 Views

I've reported this issue to our Developer. Internal bug is CMPLRIL0-32339

Viet_H_Intel
Moderator
158 Views

You can use -Qoption,cpp,--no_c++11_sfinae_ignore_access flag as a workaround. Thanks,

eldiener
New Contributor I
158 Views

Viet Hoang (Intel) wrote:

You can use -Qoption,cpp,--no_c++11_sfinae_ignore_access flag as a workaround. Thanks,

Where is this command line option documented ?

I found that "-Qoption,cpp" passes the option designated after it to the preprocessor, so it sounds like I am passing "--no_c++11_sfinae_ignore_access" to the preprocessor, but I can not find any documentation on command line switches for the preprocessor.

Also why, when the default C++ level when using Intel C++ on Windows is C++14, do I have to use some option so that a C++11 feature works correctly ?

 

eldiener
New Contributor I
158 Views

Your workaround worked but I would still like to know where the particular option passed to the preprocessor is documented. I did find preprocessor options at https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-preprocessor-options but there is no mention there of --no_c++11_sfinae_ignore_access flag.

Viet_H_Intel
Moderator
158 Views

This is an undocumented option.

eldiener
New Contributor I
158 Views

Viet Hoang (Intel) wrote:

This is an undocumented option.

Are any options for the preprocessor documented ?

Why would this be turned off by default ? SFINAE for expressions is part of the C++11 standard on up and the default compilation for Intel C++ on Windows is C++14.

Reply