Skip to content

Fix "clobbered variable" compiler warning (-Wclobbered)#600

Merged
mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom
6arms1leg:fix-type-qual
Feb 21, 2022
Merged

Fix "clobbered variable" compiler warning (-Wclobbered)#600
mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom
6arms1leg:fix-type-qual

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