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

[3.2] abieos: Fix compile warning -- throw will always call terminate() #6

Merged
merged 2 commits into from
Jul 5, 2022

Conversation

linh2931
Copy link
Member

@linh2931 linh2931 commented Jul 5, 2022

Resolve #5

abieos.cpp produces 120 occurrences of the following warnings:

tests/abieos/src/abieos.cpp:40:13: warning: throw will always call terminate() [-Wterminate]
tests/abieos/src/abieos.cpp:45:13: warning: throw will always call terminate() [-Wterminate]

The offending code is

if (!catch_all)
   throw;

while catch_all is defined as inline const bool catch_all = true;

The solution is, make catch_all constexpr, check if a preprocessor ABIEOS_NOT_CATCH_ALL is defined and set catch_all true or false accordingly; and do if constexpr.

After the changes, no more warnings are generated from aieos.cpp.

@linh2931 linh2931 requested review from larryk85 and spoonincode July 5, 2022 14:43
@swatanabe
Copy link

I think the throw should just be removed. There's no good reason to keep it. The reason that it calls terminate is that the function is declared noexcept. Calling terminate on an exception is wrong in general and is only useful in specialized cases. It was added in a4718fb.

@linh2931
Copy link
Member Author

linh2931 commented Jul 5, 2022

Thanks Steve. The throw will be removed.

@linh2931 linh2931 merged commit aeeab18 into main Jul 5, 2022
@linh2931 linh2931 deleted the fix_compile_warnings branch July 5, 2022 18:50
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.

Compile warning: throw will always call terminate() in abieos.cpp
3 participants