Community
cancel
Showing results for 
Search instead for 
Did you mean: 
87 Views

__func__ in template class

Hi,

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

>cat foo.cc
class LogDebug
{
  public:
    template< class T > LogDebug &operator<< (T const&) { return *this; }
};
class TestA {
  public:
   TestA(){LogDebug() <<__func__;}
};
template<class T>
class TestB {
  public:
   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?

0 Kudos
6 Replies
TimP
Black Belt
87 Views

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.

QIAOMIN_Q_
New Contributor I
87 Views

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.
--
QIAOMIN.Q
Intel Developer Support

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

87 Views

thanks

TimP
Black Belt
87 Views

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?).

QIAOMIN_Q_
New Contributor I
87 Views

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 15.0.0.090 Build 20140723
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.
 

Thank you.
--
QIAOMINQ.
Intel Developer Support

 

87 Views

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

Reply