Skip to content

Commit

Permalink
Workaround for GCC 12 bug in warning
Browse files Browse the repository at this point in the history
  • Loading branch information
P-p-H-d committed Feb 3, 2025
1 parent b605531 commit 033deac
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions tests/test-mtry.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
#include <stdio.h>
#include <stdbool.h>

#ifdef __GNUC__
#if __GNUC__ >= 12
/* Issue with GCC 12. It reports a variable as being not initialized
whereas it is obviously initialized.
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109530
*/
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
#endif
#endif

# if !defined(__cplusplus)
// The test shall finish with a raise fatal.
#define M_RAISE_FATAL(...) do { \
Expand Down Expand Up @@ -399,24 +410,9 @@ static void test3(void)
assert(flow ++ == 0);
M_TRY(test1) {
assert(flow ++ == 1);
#ifdef __GNUC__
#if __GNUC__ >= 13
/* Issue with GCC 13. It reports a variable as being not initialized
whereas it is obviously initialized.
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109530
*/
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
#endif
#endif
M_DEFER( assert(flow++ == 3) ) {
assert(flow ++ == 2);
}
#ifdef __GNUC__
#if __GNUC__ >= 13
_Pragma("GCC diagnostic pop")
#endif
#endif
} M_CATCH(test1, M_ERROR_MEMORY) {
assert(0);
}
Expand Down Expand Up @@ -643,6 +639,12 @@ static void test_final(void)
#endif
}

#ifdef __GNUC__
#if __GNUC__ >= 12
_Pragma("GCC diagnostic pop")
#endif
#endif

int main(void)
{
test1();
Expand Down

0 comments on commit 033deac

Please sign in to comment.