Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

ICE with icpc 15.0.0.090 on std::enable_if

Walter_D_
Beginner
450 Views

I have a problem with compiling code that works fine with gcc 4.8.1 or clang 3.5. At first, icc refused to compile it claiming (incorrectly) that my code had more than one instance of an overloaded template function (where I was using SFINAE). When working around this bug (by replacing a single template function with several overloaded non-template functions), I got:

/cm/shared/apps/gcc/4.8.1/include/c++/4.8.1/type_traits(1766): internal error: assertion failed: lower_constant: bad kind (shared/cfe/edgcpfe/lower_il.c, line 5804)

      struct enable_if
             ^


I attach the preprocessed file triggering this -- I couldn't produce a brief example :-(

Note:

icpc -V
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.0.090 Build 20140723

0 Kudos
3 Replies
Brandon_H_Intel
Employee
450 Views

Hi Walter,

Thanks for the test case. I was able to reproduce the internal error, which I'll be submitting, however, I noticed something that may help you identify a workaround here. I noticed in your .i the following code:

 

# 51 "inc/compiler.h"





















namespace intel_hack {
  template<typename T> using id=T;
}

 

And this intel_hack::id seems to get used a lot of places in standard headers when referencing decltypes, like so:

  template <typename _Tp, typename _Dp = default_delete<_Tp> >
    class unique_ptr
    {

      class _Pointer
      {
        template<typename _Up>
          static typename _Up::pointer __test(typename _Up::pointer*);

        template<typename _Up>
          static _Tp* __test(...);

        typedef typename remove_reference<_Dp>::type _Del;

      public:
        typedef intel_hack::id< decltype(__test<_Del>(0))> type;
      };

 

I noticed in my reduced test case, where I have only one of these references, if I remove the intel_hack id, and change the line to:

typedef decltype(__test<_Del>(0)) type;

The error goes away. There's a lot of these in the .i file though. I'm wondering if maybe your headers here were working around a C++11 incompatibility with an Intel compiler several versions ago, and that this workaround is no longer needed with the 15.0 compiler. You may be able to remove this workaround on your side fairly easily, perhaps, if that's the case, and it may be worth trying.

0 Kudos
Walter_D_
Beginner
450 Views

Hi Brandon,

you spotted the problem that caused the original issue. My hack to circumvent shortcomings of previous versions of icc was still in place, but that was not fully adequat. So removing that hack solved my problem and also the ICE. (however, meanwhile I found another one).

thanks, Walter.

PS. How to close this thread?

0 Kudos
Brandon_H_Intel
Employee
450 Views

Hi Walter,

Good to hear. I've still submitted a problem report to our front-end team on this since we should never internal error. I'll still update the thread when this is resolved in case anyone else is interested.

0 Kudos
Reply