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

Resolve warnings when compiling with GCC 12 and GCC 13.1 #257

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
compiler: [clang, gcc]
compiler: [clang, gcc, gcc-12]
exclude:
- os: macos-latest
compiler: gcc
- os: macos-latest
compiler: gcc-12

runs-on: ${{ matrix.os }}

# See design.mps.tests.ci.run.posix.
steps:
- uses: actions/checkout@v3
- run: ${{ matrix.compiler }} --version
- run: CC=${{ matrix.compiler }} ./configure
- run: make
- run: make test
Expand Down
2 changes: 1 addition & 1 deletion code/arenavm.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ static Res VMArenaCreate(Arena *arenaReturn, ArgList args)
VM vm = &vmStruct;
Chunk chunk;
mps_arg_s arg;
char vmParams[VMParamSize];
char vmParams[VMParamSize] = {0}; /* suppress uninitialized warning from GCC 12.2 */

AVER(arenaReturn != NULL);
AVERT(ArgList, args);
Expand Down
24 changes: 22 additions & 2 deletions code/ss.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ss.c: STACK SCANNING
*
* $Id$
* Copyright (c) 2001-2020 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2023 Ravenbrook Limited. See end of file for license.
*
* This scans the mutator's stack and fixes the registers that may
* contain roots. <design/stack-scan>.
Expand Down Expand Up @@ -30,12 +30,32 @@ SRCID(ss, "$Id$");
* stack by the caller below its other local data, so as long as
* it does not use something like alloca, the address of the argument
* is a hot stack pointer. <design/ss#.sol.stack.hot>.
*
*/

ATTRIBUTE_NOINLINE
void StackHot(void **stackOut)
{
/* GCC 13.1 legitimately complains about us leaking a dangling
pointer (-Wdangling-pointer) -- it's exactly what we are trying to
do. Rather that suppressing this warning globally, we use
Diagnostic Pragmas
<https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html> to
suppress the warning only here. */
#if CONFIG_BUILD_GC
# pragma GCC diagnostic push
/* Prevent GCC 11 and GCC 12 producing warnings that they don't know
about -Wdangling-pointer and -Wunknown-warning-option. */
# pragma GCC diagnostic ignored "-Wpragmas"
# pragma GCC diagnostic ignored "-Wunknown-warning-option"
# pragma GCC diagnostic ignored "-Wdangling-pointer"
#endif

*stackOut = &stackOut;

#if CONFIG_BUILD_GC
# pragma GCC diagnostic pop
#endif
}


Expand Down Expand Up @@ -71,7 +91,7 @@ Res StackScan(ScanState ss, void *stackCold,

/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2020 Ravenbrook Limited <https://www.ravenbrook.com/>.
* Copyright (C) 2001-2023 Ravenbrook Limited <https://www.ravenbrook.com/>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down