icpc 14.0 compiler bug

icpc 14.0 compiler bug

After the upgrade of premier.intel.com I can't login anymore, so posting here a small reproducer for a bug in icpc 14.0.0, see below.

[build@fc19jslave09 ~]$ cat t.cpp
#include <type_traits>
class T_base;
template<typename T,
         typename = typename std::enable_if<
           std::is_base_of<T_base, T>::value>::type, typename ...Args>
void f(T const&);

template<typename T,
         typename = typename std::enable_if<
           std::is_base_of<T_base, T>::value>::type, typename ...Args>
inline void f(T const&)
{
}

[build@fc19jslave09 ~]$ icpc -std=c++0x -c  t.cpp
t.cpp(9): error: redefinition of default argument
           typename = typename std::enable_if<
                    ^

compilation aborted for t.cpp (code 2)
[build@fc19jslave09 ~]$ g++ -std=c++11 -c t.cpp
[build@fc19jslave09 ~]$ g++ --version
g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[build@fc19jslave09 ~]$ icpc --version
icpc (ICC) 14.0.0 20130728
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

附件尺寸
下载 icc14bug.txt4.06 KB
12 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

>>#include "type_traits"
>>class T_base;
>>template> typename = typename std::enable_if<
>> std::is_base_of::value>::type, typename ...Args>
>>void f(T const&);
>>
>>template> typename = typename std::enable_if<
>> std::is_base_of::value>::type, typename ...Args>
>>inline void f(T const&)
>>{
>>}

I've completed a verification on a Windows platform and there are No any problems with the test case ( successfully compiled even with older version 12 of Intel C++ ompiler ).

Did you try std=c++0x command line option?

Yes, the exact output is above, see that this is the Intel C++ 14 compiler on Linux, installed it on a Fedora 19 box

>>...Did you try std=c++0x command line option?

Sorry, I see that you've used it.

I have a similar problem on MacOs X 10.8 (same version of the compiler) with the following code
cat test.cpp

#include
int main()
{
}

it compiles with g++/opt/softs/gcc/4.7.2/bin/g++ -o t test.cpp -std=c++11
but with icpc 14.0 i obtain
icpc -o t test.cpp -std=c++11

test.cpp(1): catastrophic error: cannot open source file "type_traits"
#include

compilation aborted for test.cpp (code 4)

Any idea
Thanks

icpc --version
icpc (ICC) 14.0.0 20130716
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

Hiepacs project Centre de Recherche Bordeaux Sud-Ouest Bâtiment A 29Bis - 351, cours de la Libération F-33 405 Talence Cedex Tel: [33] (0)5 24 5740 80 Mail: Olivier.Coulaud@inria.fr

If you have an empty #include it appears to be a simple failure to find a corresponding source file, aside from the questionable error report.

I don't know about putting -std option after the source file.

For me, it gives a more explicit message:

test.cpp(1): catastrophic error: expected a file name
  #include
          ^

Looks the Developer Forum zapped some text at some point, in the textual email related to the update type_traits was listed as filename after the included file. Independent of this, this looks a complete different issue, if it can't find type_traits it looks an installation problem, not related to mine.

Hi, 

Oups bad copy past, 

HEre the minimal code

#include <type_traits>
int main()
{

}

the result

icpc -o t test.cpp -std=c++11
test.cpp(1): catastrophic error: cannot open source file "type_traits"
#include <type_traits>
^

compilation aborted for test.cpp (code 4)

Hiepacs project Centre de Recherche Bordeaux Sud-Ouest Bâtiment A 29Bis - 351, cours de la Libération F-33 405 Talence Cedex Tel: [33] (0)5 24 5740 80 Mail: Olivier.Coulaud@inria.fr

@Olivier, this looks really a setup problem, the compiler should be able to find this file

Regarding the default argument redefinition error:

This is a valid error. You are not allowed by the C++ standard to redefine a default argument, (even to the same value). But we need to allow it since GNU allows it so we are tracking this in our bug database as a GNU compatibility as DPD 200385046. Thanks for reporting it. In the meantime you can/should fix your code by removing the duplicate default argument on the definition.

Some relevant discussions are:

http://stackoverflow.com/questions/2842928/default-value-of-function-parameter

http://stackoverflow.com/questions/4989483/where-to-put-default-parameter-value-in-c

http://stackoverflow.com/questions/6210450/the-compiler-is-complaining-about-my-default-parameters

Judy

 

Regarding the lack of the header file <type_traits>, this was added by C++11 so older versions of GNU will not have it (I think it got added in GNU version 4.3). So do a g++ -v to see what version of the GNU header files you using. Intel does not provide its own set of headers/libraries, it just uses whatever is already installed on your system.

Judy

Yes, this is a GCC specific feature which also has been confirmed as GCC bug, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50370

登陆并发表评论。