Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] Fix reflection build for gcc-8 #1304

Merged
merged 1 commit into from
Jun 20, 2018
Merged

[BUILD] Fix reflection build for gcc-8 #1304

merged 1 commit into from
Jun 20, 2018

Conversation

tqchen
Copy link
Member

@tqchen tqchen commented Jun 20, 2018

https://discuss.tvm.ai/t/tvm-with-gcc-8-1-build-errors/286

The error was due to gcc-8 have some problem redirecting to the right operator T (where T is double, or int) inside the inside a template function. This PR introduces a workaround of that

Minimum Example to Demonstrate the Problem

#include <type_traits>

class MyClass {
 public:
  operator double() const {
    return 1;
  }
  template<typename T>
  operator T() const {
    static_assert(std::is_class<T>::value, "problem");
    return T();
  }
};

template<typename T>
void SetValue(const MyClass& obj, T* value) {
  *value = obj.operator T();
}

int main() {
  MyClass obj;
  // works fine                                                                                                                              
  obj.operator double();
  double x;
  // error;                                                                                                                                  
  SetValue(obj, &x);
}

@tqchen
Copy link
Member Author

tqchen commented Jun 20, 2018

confirmed as a regression of gcc https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86246

@tqchen tqchen merged commit 3611a5a into apache:master Jun 20, 2018
tqchen added a commit to tqchen/tvm that referenced this pull request Jul 6, 2018
mnuyens pushed a commit to mnuyens/tvm that referenced this pull request Jul 10, 2018
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant