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

Fix misplaced assert statement causing a lot of warnings #2988

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

muffgaga
Copy link
Contributor

@muffgaga muffgaga commented Nov 14, 2023

I just saw this warning quite often (in the EBRAINS spack build it gets repeated for 162 times ;) ):

/tmp/spack-stage/spack-stage-nest-3.6-uy4os6lc7odhv7bryyp2atuprbdl2xwn/spack-src/nestkernel/connection.h: In member function 'nest::SecondaryEvent* nest::Connection<targetidentifierT>::get_secondary_event()':
/tmp/spack-stage/spack-stage-nest-3.6-uy4os6lc7odhv7bryyp2atuprbdl2xwn/spack-src/nestkernel/connection.h:404:1: warning: no return statement in function returning non-void [-Wreturn-type]
  404 | }
      | ^

Also: I guess even if the assert is ensured to never be removed (contrary to standard NDEBUG behavior) it would be reasonable to clearly state the intention here (an exception might be more user-friendly, but I guess the code was intentionally avoiding an exception) by calling abort?

@gtrensch gtrensch added T: Enhancement New functionality, model or documentation S: Normal Handle this with default priority I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Nov 17, 2023
Copy link
Contributor

@terhorstd terhorstd left a comment

Choose a reason for hiding this comment

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

minor change

nestkernel/connection.h Outdated Show resolved Hide resolved
Copy link
Contributor

@gtrensch gtrensch left a comment

Choose a reason for hiding this comment

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

Approved.

@terhorstd terhorstd changed the title chore: fix warning Fix misplaced assert statement causing a lot of warnings Nov 17, 2023
Copy link
Contributor

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

@muffgaga Thanks for this fix! Which compiler and which compiler options do you use? I have not seen this warning before, so our warning settings are apparently not strict enough. Also, even though the limited "Schaffungshöhe" of this PR does not strictly make it necessary, would you send us a contributor agreement (https://nest-simulator.readthedocs.io/en/latest/_downloads/9b65adbdacba6bfed66e68c62af4e308/NEST_Contributor_Agreement.pdf)?

nestkernel/connection.h Outdated Show resolved Hide resolved
nestkernel/connection.h Outdated Show resolved Hide resolved
nestkernel/connection.h Outdated Show resolved Hide resolved
@muffgaga
Copy link
Contributor Author

muffgaga commented Nov 17, 2023

@muffgaga Thanks for this fix! Which compiler and which compiler options do you use? I have not seen this warning before, so our warning settings are apparently not strict enough.

It was the EBRAINS Software environment/Collab one — i.e. [email protected], and "Release" build was mentioned in the build log (see #2993 for a build issue using the same compiler/software environment). (Maybe NDEBUG was set — I did not investigate deeper → I can, if requested.)

Also, even though the limited "Schaffungshöhe" of this PR does not strictly make it necessary, would you send us a contributor agreement (https://nest-simulator.readthedocs.io/en/latest/_downloads/9b65adbdacba6bfed66e68c62af4e308/NEST_Contributor_Agreement.pdf)?

Yes, will do.

@muffgaga
Copy link
Contributor Author

NEST_Contributor_Agreement

Yes, will do.

→ sent to @terhorstd (he asked me directly via chat).

In release builds, the assert is omitted and the function shows undefined
behavior due to not returning.
We now return nullptr to avoid UB; in general we expect developers to build
in non-release mode, and to encounter the assert when code wrongly dispatches
to this function.
nestkernel/connection.h Outdated Show resolved Hide resolved
Co-authored-by: Hans Ekkehard Plesser <[email protected]>
@heplesser
Copy link
Contributor

@muffgaga Thanks a lot, will merge now!

@heplesser heplesser requested review from terhorstd and removed request for terhorstd December 1, 2023 11:41
@heplesser
Copy link
Contributor

@terhorstd Since you had previously requested changes to this PR, you need to approve it now :).

Copy link
Contributor

@terhorstd terhorstd left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thanks!

@terhorstd terhorstd added T: Maintenance Work to keep up the quality of the code and documentation. and removed T: Enhancement New functionality, model or documentation labels Dec 13, 2023
@terhorstd terhorstd merged commit 61b5d40 into nest:master Dec 13, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants