Skip to content

clean up Zicntr #366

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

Merged
merged 1 commit into from
Jan 27, 2025
Merged

clean up Zicntr #366

merged 1 commit into from
Jan 27, 2025

Conversation

leekillough
Copy link
Collaborator

Clean up Zicntr to use [[noreturn]], declare destructor, and simplify if-code.

return make_dependent<T>( GetCore() )->output->fatal( CALL_INFO, -1, msg, GetPC() );
[[noreturn]] void fatal( const T* msg ) const {
make_dependent<T>( GetCore() )->output->fatal( CALL_INFO, -1, msg, GetPC() );
std::terminate();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked that Output::fatal calls std::exit so is std::terminate() there to satisfy the compiler? If we did a PR to change void Output::fatal to use [[noreturn]] would this eliminate the need for std::terminate(). I'm thinking that since this is used frequently in SST code it might be worth it to open an SST PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already fixed SST to use [[noreturn]] on Output::fatal(), but older versions of SST do not have that attribute, so std::terminate() is called afterwards to prevent compiler warnings about a [[noreturn]]-declared function (our fatal()function) possibly returning anyway because in previous versions of SST it doesn't know that Output::fatal() never returns, so we just add std::terminate() to tell the compiler that regardless of whether Output::fatal() returns, our fatal() function never returns and thus it abides by the [[noreturn]] attribute we declared it with. Otherwise we might get the warning Warning: Function declared [[noreturn]] reaches end of function or the like.

Copy link
Collaborator

@kpgriesser kpgriesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the 1 comment regarding if we should consider an sst pr

@leekillough
Copy link
Collaborator Author

just the 1 comment regarding if we should consider an sst pr

It was already filed and fixed months ago. See here and here.

But because we are ultra-strict about compiler warnings as errors, we must guard against the compiler thinking that our [[noreturn]] function may, in fact, return.

@leekillough
Copy link
Collaborator Author

void might_return();

[[noreturn]] void may_return() {
  might_return();
}

g++ -c may_return.cpp -Werror

$g++ -c may_return.cpp -Werror
may_return.cpp: In function ‘void may_return()’:
may_return.cpp:5:1: error: ‘noreturn’ function does return [-Werror]
    5 | }
      | ^
cc1plus: all warnings being treated as errors

With std::terminate():

#include <exception>

void might_return();

[[noreturn]] void may_return() {
  might_return();
  std::terminate();
}

g++ -c may_return.cpp -Werror

(no error)

@leekillough leekillough merged commit e4ed896 into devel Jan 27, 2025
@leekillough leekillough deleted the cleanup_zicntr branch January 27, 2025 18:06
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.

2 participants