Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Customer__Intel5
Beginner
126 Views

[bugreport] Bug when defining method out of class

Hi there. The following C++11 code fails to compile correctly:

 

#include <utility>

template <class F> struct foo {
  template <class... Args>
  auto operator()(Args &&... args)
      -> decltype(std::declval<F>()(std::forward<Args>(args)...));
};
template <class F>
template <class... Args>
auto foo<F>::operator()(Args &&... args)
    -> decltype(std::declval<F>()(std::forward<Args>(args)...)) {
  return F()(std::forward<Args>(args)...);
}

struct fun {
  int operator()(int) { return 0; }
};

int main() { return foo<fun>()(1); }

I get no compilation error with clang++ or g++...

0 Kudos
12 Replies
MalReddy_Y_Intel
Employee
126 Views

Hi,

Just FYI, This issue has been addressed in the 17.0 beta compiler which is available in the below link.

https://software.intel.com/en-us/articles/intel-parallel-studio-xe-2017-beta

Thanks,

Reddy

Kittur_G_Intel
Employee
126 Views

Thanks Reddy, yes this is fixed in the beta compiler.

Kittur

Customer__Intel5
Beginner
126 Views

Unfortunately, I managed to trigger a similar bug with the beta version. I'm still struggling to build a minimal working example.

It's part of a bigger goal: trying to use icpc as a backend compiler for the pythran project (http://pythonhosted.org/pythran). Pythran runtime headers compile fine with g++ and clang++, but icpc chokes on it.

Kittur_G_Intel
Employee
126 Views

Hi @sguelton,
I cannot reproduce with test samples on my end including the one you indicated in this thread. Appreciate if you can create a test reproducer. Can you compile with -P option to generate a preprocessed file and attach the generated .I file so I can reproduce the issue? Thanks for your help.

Kittur

Customer__Intel5
Beginner
126 Views

Hi Kittur, the (very large) preprocessed file is in attachment. Hope it helps...

If you manage to compile this file as clang and gcc does, I'll be able to officially support pythran + icc, which would be great news!

Judith_W_Intel
Employee
126 Views

 

Thanks for the test case. I was able to reduce it to the following which does get a spurious error using our latest compiler:

Spurious errors:

sptxl15-489> icpc -std=c++11 -c bug.cpp
bug.cpp(33): error: declaration is incompatible with "auto C<Arg>::foo(int)->Arg" (declared at line 28)
  auto C<Arg>::foo(int i) -> decltype(this->fast(i))
               ^

bug.cpp(33): error: "this" may only be used inside a nonstatic member function
  auto C<Arg>::foo(int i) -> decltype(this->fast(i))
                                      ^

compilation aborted for bug.cpp (code 2)
sptxl15-490>

// bug.cpp

template <class Arg>
struct C {
   Arg fast(int i);
   auto foo(int i) -> decltype(this->fast(i));
   template <class E> C<C> fast(E const &expr) const;  // somehow this overload causes problem
};

template <class Arg>
auto C<Arg>::foo(int i) -> decltype(this->fast(i))
{
  return true;
}

I have submitted a bug report in our internal bugs database under the number DPD200409734.

Again, thanks for letting us know...

Judy

Kittur_G_Intel
Employee
126 Views

Great, thanks Judy I'll monitor this issue and let @sguelton, know as soon as the release with the fix is out.

Hi @sguelton - thanks for the reproducer and I'll keep you updated on the progress of this issue.

Kittur

Customer__Intel5
Beginner
126 Views

Thanks a lot Kittur and Judith! Let me know when I can download a new icc (preview version) and run it on the whole pythran database. That's a very good test case for icc :-)

Kittur_G_Intel
Employee
126 Views

Sure, will do. Again, thanks for your patience through this towards resolution.

Kittur

Customer__Intel5
Beginner
126 Views

Hi there,

I've downloaded and tried the last icpc release, namely icpc (ICC) 16.0.3 20160415

It still fails to compile some basic pythran-generated programs... I'm attaching a faulty preprocessed source. Hope it helps!

Kittur_G_Intel
Employee
126 Views

Thanks for letting us know. I'll look into reproducing the issue on your new attached .I file and will pass on the info to the team - appreciate much.

Regards,
Kittur

Customer__Intel5
Beginner
126 Views

Hi there - topic revival.

I've checked the latest release, and the problem is still there... any status on this?

Reply