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 "clobbered variable" compiler warning (-Wclobbered) #600

Merged
merged 1 commit into from
Feb 21, 2022

Conversation

6arms1leg
Copy link
Contributor

@6arms1leg 6arms1leg commented Feb 21, 2022

This PR adds a missing volatile type qualifier to fix a "clobbered variable" compiler warning (-Wclobbered).

Compiling the unit tests with the -Wclobbered compiler flag (or -Wextra, which includes -Wclobbered) produces the following warning:

warning: variable ‘e’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]

The CExeption README states that

If (a) you change local (stack) variables within your Try block, and (b) wish to make use of the updated values after an exception is thrown, those variables should be made volatile.

I believe both conditions apply to the variable I added the volatile type qualifier to.
This is supported by this SO answer and this SO answer.

Now, the compiler issues no warning when compiled with the -Wclobbered or -Wextra flag.

... to fix "clobbered variable" compiler warning (`-Wclobbered`).
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