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

Compile warning: throw will always call terminate() in abieos.cpp #5

Closed
linh2931 opened this issue Jun 30, 2022 · 0 comments · Fixed by #6
Closed

Compile warning: throw will always call terminate() in abieos.cpp #5

linh2931 opened this issue Jun 30, 2022 · 0 comments · Fixed by #6
Assignees

Comments

@linh2931
Copy link
Member

abieos.cpp produces 120 occurrences of warnings (out of 380) in a mandel build. Please see below for discussions on telegram.

Lin Huang, [Jun 30, 2022 at 1:50:47 PM]:

The following two warnings occur 120 times (out of 380 total) in a mandel build:

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;

As catch_all is a constant and I cannot find anywhere it is set to false, the throw is never executed. Is it safe to just remove catch_all and the if statement?

Bucky, [Jun 30, 2022 at 2:12:50 PM]:
I don't think it would be a problem to outright remove it.

But, you could also make the bool catch_all inline constexpr and do if constexpr instead. And check if a preprocessor define (maybe ABIEOS_CATCH_ALL) is defined and set to true or false accordingly.

I suspect this is there to help with debugging during development as it is will eat a lot of exceptions.

Actually the obverse is what you want. ABIEOS_NOT_CATCH_ALL so the default behavior can be to catch all.

Lin Huang, [Jun 30, 2022 at 2:29:08 PM]:
Thanks @larryk85 for your suggestions. They will get rid of the warnings, do it at compile time, and keep a way for debugging.

Matt Witherspoon, [Jun 30, 2022 at 2:35:32 PM]:
my hunch is it exists for when you embed abieos in to another language that won't be able to cope with c++ exceptions. think JNI etc

@linh2931 linh2931 moved this to Todo in ENF Engineering Jun 30, 2022
@linh2931 linh2931 changed the title warning: throw will always call terminate() in abieos.cpp Compile warning: throw will always call terminate() in abieos.cpp Jul 5, 2022
@linh2931 linh2931 self-assigned this Jul 5, 2022
@linh2931 linh2931 moved this from Todo to In Progress in ENF Engineering Jul 5, 2022
@linh2931 linh2931 moved this from In Progress to Awaiting Review in ENF Engineering Jul 5, 2022
Repository owner moved this from Awaiting Review to Done in ENF Engineering Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
1 participant