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

GCC 6.1 compilation error #1000

Closed
taranco opened this issue Jul 1, 2016 · 4 comments
Closed

GCC 6.1 compilation error #1000

taranco opened this issue Jul 1, 2016 · 4 comments

Comments

@taranco
Copy link

taranco commented Jul 1, 2016

When attempting to compile nupic.core with gcc 6.1 the following error occurs:

/home/rts/src/nupic.core/src/nupic/engine/Output.cpp: In destructor 'nupic::Output::~Output()':
/home/rts/src/nupic.core/src/nupic/engine/Output.cpp:51:36: error: throw will always call terminate() [-Werror=terminate]
   NTA_CHECK(links_.size() == 0) << "Internal error in region deletion";
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/rts/src/nupic.core/src/nupic/engine/Output.cpp:51:36: note: in C++11 destructors default to noexcept
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/nupic_core_solo.dir/build.make:1288: src/CMakeFiles/nupic_core_solo.dir/nupic/engine/Output.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:765: src/CMakeFiles/nupic_core_solo.dir/all] Error 2
make: *** [Makefile:150: all] Error 2

Using the flag -Wno-error=terminate seems to solve the problem. Nupic.core compiles an pass the tests. I suggest take this into account (CommonCompilerConfig.cmake) when this version of gcc is detected.

@vitaly-krugl
Copy link
Member

@taranco, could you elaborate on the build environment, including version of nupic.core, the operating system and its version? Thank you.

@vitaly-krugl
Copy link
Member

vitaly-krugl commented Jul 1, 2016

I see, it's a feature of GCC6. I came across this description:

-Wterminate (enabled by default) warns when a throw will immediate result in a call to terminate like in an noexcept function. In particular it will warn when something is thrown from a C++11 destructor since they default to noexcept, unlike in C++98 (GCC6 defaults to -std=gnu++14)."

in https://gnu.wildebeest.org/blog/mjw/2016/02/15/looking-forward-to-gcc6-many-new-warnings/.

See also http://en.cppreference.com/w/cpp/language/noexcept_spec

@vitaly-krugl
Copy link
Member

vitaly-krugl commented Jul 1, 2016

The culprit function is the destructor:

Output::~Output()
{
  // If we have any outgoing links, then there has been an 
  // error in the shutdown process. Not good to thow an exception
  // from a destructor, but we need to catch this error, and it 
  // should never occur if nupic internal logic is correct. 
  NTA_CHECK(links_.size() == 0) << "Internal error in region deletion";
  delete data_;
}

C++ has no mechanism for passing an exception out of a destructor (the GCC6 runtime calls terminate() instead), thus exceptions raised inside a destructor look questionable to the compiler.

@taranco
Copy link
Author

taranco commented Jul 1, 2016

It's Arch Linux (GNU/Linux) @vitaly-krugl:

Linux   4.6.3
GCC     6.1.1 20160602
Cmake   3.5.2
Make    4.2.1

Nupic.core     0.4.5.dev0 (Last from git)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants