__func__ in template class

__func__ in template class


  while trying to compile following code using "icc compiler 15.0.0", I am getting this error

>cat foo.cc
class LogDebug
    template< class T > LogDebug &operator<< (T const&) { return *this; }
class TestA {
   TestA(){LogDebug() <<__func__;}
template<class T>
class TestB {
   TestB(){LogDebug() <<__func__;}
template class TestB<int>;
>icpc -v
icpc version 15.0.0 (gcc version 4.7.2 compatibility)
>icpc -c -std=c++0x -o foo.o foo.cc
foo.cc(15): error: no operator "<<" matches these operands
            operand types are: LogDebug << const char [18]
     TestB(){LogDebug() <<__func__;}
          detected during instantiation of "TestB<T>::TestB() [with T=int]" at line 18

compilation aborted for foo.cc (code 2)

If I drop the -std=c++0x flag then it compiles but then most of our other code does not compile. Any idea what is wrong here?

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I would have thought -std=c++11 would be more likely to work with g++ 4.7 or later on PATH.

The version of 15.0 update 1 which I tried first supports the gcc version compatibility flag only up to 460, and when I set that and std=c++11, I get ICE on your case.  Without the gcc compatibility flag, this compilation completed without remark.

I guess I'll submit a ticket, since that used to be the preferred way to discuss beta compilers.

Hello Malik,

I have reproduced as you said ,and have entered this issue into our problem-tracking database.Thank you for submitting the issue.I'll get this posted whenever I have an update from development team.

Thank you.
Intel Developer Support

Please participate in our redesigned community support web site:
Tools Knowledge Base:           http://software.intel.com/en-us/articles/tools


Qiaomin marked the issue as resolved and closed with the "latest" compiler release.  He wasn't specific about whether this means 14.0 update or 15.0 release, or both, nor about the fix (does gcc version compatibility work when a recent gcc version is specified?).

Hello Timp,

I have verified that this compiles fine with the new ICC versions

$ icpc -c -std=c++0x -o foo.o foo.cc                               //ok

$ icc -v
icc version 15.0.0 (gcc version 4.4.6 compatibility)
$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version Build 20140723
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

Thank you.
Intel Developer Support


Thanks a lot, I will give it a try once we have the new version available.

Leave a Comment

Please sign in to add a comment. Not a member? Join today